0
我下面的代碼使IOS刷卡刪除功能並刪除行。問題是底層的數據結構沒有被刪除。我有3個單元格,Google-Bing-Yahoo,如果我刪除Google單元格刪除但Bing上移,變成indexPath.row 0並繼承谷歌以前的操作。我在哪裏錯過了「嘿,刪除行動到這個單元格」呼籲。或者也許這是我分配細胞的方式?我應該使用標籤嗎?刷卡刪除沒有刪除底層數據結構
////My Array
someData = [[NSMutableArray alloc]init];
[someData addObjectsFromArray:[NSMutableArray arrayWithObjects: @"Google", @"Bing", @"Yahoo", nil]];
////Allow cell editing & remove data
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
// Remove the row from data model
[someData removeObjectAtIndex:indexPath.row];
// Request table view to reload
[tableView reloadData];
}
////Cell Chosen Action
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.row == 0) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://google.com"]];
}
if(indexPath.row == 1) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://bing.com"]];
}
if(indexPath.row == 2) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://yahoo.com"]];
}
有道理。所以這是我的任務方法。謝謝。 – Jesse