选择性UITableView删除单元格?

时间:2011-04-13 04:29:33

标签: cocoa-touch xcode ios4 uitableview

我有一个带有队列的图片应用程序。我希望用户能够从中删除图像,但不能删除正在上传的图像。所以我有这样的事情:

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {

//NSString *indexPathString = [NSString stringWithFormat:@"%d", indexPath];
NSString *theObject = [processList objectAtIndex:0];

NSLog(@"theObject: %@", theObject);

NSString *theStatus;
NSArray *resultstwoo = [database executeQuery:@"SELECT * FROM processes WHERE image=?", theObject]; 
for (NSDictionary *rowtwoo in resultstwoo) {
    theStatus = [rowtwoo valueForKey:@"status"];
}

NSLog(@"the status: %@", theStatus);

if ([theStatus isEqualToString:@"Uploading..."]) {
    return UITableViewCellEditingStyleNone;
} else if ([theStatus isEqualToString:@"Resizing..."]) {
    return UITableViewCellEditingStyleNone;
} else {
    return UITableViewCellEditingStyleDelete;
}

}

即使我的NSLog说它是“正在上传...”,它仍会显示删除按钮。

请帮助,谢谢:
库尔顿!

1 个答案:

答案 0 :(得分:0)

你试过

吗?
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the specified item to be editable.
return YES;
}

如果上传会让它返回NO吗?