我通過設置標籤用於騙取actionSheet = indexpath.row
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
// If row is deleted, remove it from the list.
if (editingStyle == UITableViewCellEditingStyleDelete)
{
UIActionSheet *registerActionSheet = [[UIActionSheet alloc] initWithTitle:@"Sure You Want To Delete?"delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:ACTION_SHEET_DELETE_BUTTON_TITLE otherButtonTitles: nil];
registerActionSheet.tag = indexPath.row;
registerActionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[registerActionSheet showInView:self.view];
}
}
然後
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
if ([[actionSheet buttonTitleAtIndex:buttonIndex] isEqualToString:ACTION_SHEET_DELETE_BUTTON_TITLE]) {
//do deleting stuff here using actionSheet.tag as index
}
}
編輯:剛纔看到微妙的多個部分你使用。通過向它添加indexPath屬性來擴展UIActionSheet將有助於您的情況?
或將標記設置爲'x'位數,前半部分表示部分,後半部分表示行。