我想知道如何在PFQueryTableView
. 我的表格视图运行良好,可以正确加载所有 PFObject。但是,我想在表格视图底部添加一个新行,这样当我点击它时,它会弹出另一个视图控制器来创建一个新的PFObject
. 与PFQueryTableViewController
它一起Edit Button
只允许删除PFObject。你能帮我吗?
在-viewDidLoad
self.navigationItem.rightBarButtonItem = self.editButtonItem;
在-tableView:numberOfRowsInSection:
return self.tableView.isEditing ? self.objects.count + 1 : self.objects.count;
在-tableView:cellForRowAtIndexPath:object:
BOOL isInsertCell = (indexPath.row == self.objects.count && tableView.isEditing);
NSString *CellIdentifier = @"CustomCell";
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
cell = [topLevelObjects objectAtIndex:0];
}
// Configure the cell
UILabel *cellLocationLabel = (UILabel *)[cell.contentView viewWithTag:100];
cellLocationLabel.text = isInsertCell ? @"Add a new location" : [object objectForKey:@"address"];
return cell;