ユーザーが電話を振ったときにテーブル ビューから行を削除する iPhone アプリケーションを開発しています。ナビゲーション ベースのプロジェクトを作成しました。ユーザーが iPhone を振ると、ナビゲーション バーのタイトルが "DELETE" に変わり、同じビューでナビゲーション バーに削除ボタンが表示されます。それ以外の場合、ユーザーが特定の行を選択すると、次のビューに移動する必要があります。以下のコードを書きましたが、うまくいきません。私を助けてください。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (isShaked == NO)
{
//logic to move to next view goes here.
}
else
{
self.title = @"Delete Rows";
delete=[[UIBarButtonItem alloc] initWithTitle:@"Delete rows" style:
UIBarButtonItemStyleBordered target:self action:@selector(deleteItemsSelected)] ;
self.navigationItem.rightBarButtonItem=self.delete;
MyTableCell *targetCustomCell = (MyTableCell *)[tableView cellForRowAtIndexPath:indexPath];
[targetCustomCell checkAction];
[self.tempArray addObject: [myModal.listOfStates objectAtIndex:indexPath.row]];
//[delete addTarget:self action:@selector(deleteItemsSelected:) forControlEvents:UIControlEventTouchUpInside];
self.tempTableView = tableView;
}
}
-(void)deleteItemsSelected
{
[myModal.listOfStates removeObjectsInArray:tempArray];
[tempTableView reloadData];
}
checkAction
method は、選択した行に目盛りを付けるために使用されるカスタム セル メソッドです。