1

UITableViewとカスタムセルを使用していcheckboxます。複数のセクションがあります。行 = 0 とセクション = 0 のセルなど、最初のセクションのチェックボックスをオンにすると、データが保存され、機能します。ただし、行 = 0 およびセクション = 1 のセルもチェックされます。これらのセクションの違いをどのように作ることができますか?

どうもありがとう!

4

2 に答える 2

3

次のサンプル コードは、状況に応じて役立ちます。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";

    CustomCell *cell = (CustomCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
       cell = (CustomCell *) [[[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil] objectAtIndex:0];
       cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    cell.checkBox = [self fillCheckBoxStatus:indexPath];//This method will say about check box whether going to SET or NOTSET. 
    //...
    return cell;
}
于 2013-04-19T11:59:19.940 に答える
-2

dequeueReusableCellWithIdentifierベローnil... _

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:nil];
    if (cell == nil) {

    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil] autorelease];
      ////you another code..
   }
  return cell;
}
于 2013-04-19T11:57:44.013 に答える