我想從UITableView
刪除一行。 我的UITableView
由名爲TableData
的NSMutableArray
填充。 當我刪除一行並重新加載tableview時,它顯示最後一行已被刪除[而不是所選行]。 但是,當我NSLog()
可變數組的內容,它表明選定的行已被刪除。UITableView刪除不起作用
這是我的代碼:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
[TableData removeObjectAtIndex:indexPath.row];
[tableView reloadData];
for (int i = 0; i < [TableData count]; i++)
{
NSLog(@"Value at %d :%@", i, [TableData objectAtIndex:indexPath.row]);
}
}
}
作爲Objective-C約定的問題,變量的第一個字母應該是小寫,而不是大寫(re:你的'TableData'變量) – 2010-09-08 19:18:43
好的,謝謝。我會糾正它。 – 2010-09-08 21:43:20