0
これは、tableviewcellの行を削除するためのコードです。UITableviewcell NSMutableArray配列データの代わりに辞書キーを使用して削除ボタンを表示
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
[Keys removeObjectAtIndex:indexPath.row]; // this line error
[_tableView deleteRowsAtIndexPaths:[NSMutableArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
エラー行は `[Key removeObjectAtIndex:indexPath.row]; ' 。
私はこのコードがNSMutableArrayで使用されるべきであることを知っていますが、私はこのセルを削除するためのPlistのDictionary Keysに同じ方法を使用します。
編集可能:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
CustomeCell *Customecell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (Customecell == nil){
Customecell =[[CustomeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
Customecell.nameLbl.text = [Keys objectAtIndex:indexPath.row];
Customecell.Img.image = [UIImage imageNamed:[[content valueForKey:[Keys objectAtIndex:indexPath.row]] valueForKey:@"image"]];
Customecell.statusLabel.text = [[content valueForKey:[Keys objectAtIndex:indexPath.row]] valueForKey:@"status"];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"];
// NSString *dateString = [dateFormatter stringFromDate:[NSDate date]]; // current date
NSString *dateString = [dateFormatter stringFromDate:[[content valueForKey:[Keys objectAtIndex:indexPath.row]] valueForKey:@"date"]];
NSLog(@"date: %@", dateString);
Customecell.dateLbl.text=dateString;
return Customecell;
をしてください試してみてください。 –
'tableView:cellForRowAtIndexPath:'のコードは何ですか? NSDictionaryオブジェクトがモデルデータソースとしてどのように機能するのかわからない場合、私たちはあなたを助けることはできません。 – Larme
エラーは次のとおりです。 'NSArray'の表示されない@interfaceによってセレクタ 'removeObjectAtIndex:'が宣言されます –