选择性的UITableView删除单元格?
问题描述:
我有一个带有队列的图片应用程序。我希望用户能够从中删除图像,但不能上传。所以我有这样的事情:选择性的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说它是“正在上传...”,它仍然显示删除按钮。
请帮助,谢谢:
Coulton!
答
你尝试
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the specified item to be editable.
return YES;
}
让它回归NO,如果它上传?
添加当前正在上传的行后,尝试调用'[tableview reloadRowsAtIndexPaths:indexPathsArray withRowAnimation:UITableViewRowAnimationNone]'并查看删除按钮是否消失(“indexPathsArray'是一个含有”NSIndexPath“的单元素数组它)。 – darvids0n 2011-04-13 04:37:18