私は2つのセクションを持つ動的テーブルビューを開発しています: -登録された署名 -拒否された署名
私の値はすべて、辞書内のフラグに応じて各セクションに移動します。
[[self.userSignatures objectAtIndex:indexPath.row] objectForKey:@"idFirma"]
0 の場合は署名が登録されていないことを意味し、それ以外の場合は登録済みであることを意味します。
しかし、私の方法で印刷のセクションを開発する方法がわかりません
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
これは私の開発です:
#pragma mark *** Common methods: Tableview delegate methods ***
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    if (section == 0)   return @"not registered signatures";
    return @"Registered signatures";
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    // Return the number of rows in the section.
    if ([self.userSignatures count] > 0){
        int firmasRegistradas = 0;
        for (int i = 0; i < [self.userSignatures count]; i++) {
            if (![[[self.userSignatures objectAtIndex:i] valueForKey:@"idFirma"] isEqualToString:@"0"])
                firmasRegistradas += 1;
        }
        if (section == 0)   return [self.userSignatures count] - firmasRegistradas;
        if (section == 1)   return firmasRegistradas;
    }    
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    // Configure the cell...
    UILabel     *EntidadFirmante    = (UILabel *)   [cell viewWithTag:2];
    UILabel     *statusFirma        = (UILabel *)   [cell viewWithTag:3];
    if ([self.userSignatures count] > 0) {
        EntidadFirmante.text    = [[self.userSignatures objectAtIndex:indexPath.row]objectForKey:@"titFirmante"];
        statusFirma.text        = [[self.userSignatures objectAtIndex:indexPath.row]objectForKey:@"idDoc"];
        cell.accessoryType      = UITableViewCellAccessoryDisclosureIndicator;
        NSLog(@"idFirma: %@",[[self.userSignatures objectAtIndex:indexPath.row] objectForKey:@"idFirma"]);
        if (indexPath.section == 0 && [[[self.userSignatures objectAtIndex:indexPath.row] objectForKey:@"idFirma"] isEqualToString:@"0"]) return cell;
        else
        if (indexPath.section == 1 && ![[[self.userSignatures objectAtIndex:indexPath.row] objectForKey:@"idFirma"] isEqualToString:@"0"]) return cell;
    }
    else{
        EntidadFirmante.text    = @"There's no signatures";
        statusFirma.text        = @"without signatures";
        cell.accessoryType      = UITableViewCellAccessoryNone;
    }
    return cell;
}
キーはここにあります:
if (indexPath.section == 0 && [[[self.userSignatures objectAtIndex:indexPath.row] objectForKey:@"idFirma"] isEqualToString:@"0"]) return cell;
else
if (indexPath.section == 1 && ![[[self.userSignatures objectAtIndex:indexPath.row] objectForKey:@"idFirma"] isEqualToString:@"0"]) return cell;
このようなリストがある場合
- 登録済み
- 登録済み
- 未登録
- 登録済み
私は次のようなものを期待しています:
登録署名: 1. 2. 4.
未登録の署名 3.
しかし、これまでのところ私はこのようなものを得ます
登録署名: 1. 2. 4.
未登録の署名 1. (登録済み)
登録されていない署名が 3 番目の署名である場合、最初の署名 (登録済み) が印刷されます。
私が感謝する助け