したがって、私はそれに応じて対応できるように、挿入操作と削除操作を区別する方法を決めたいと思っています。現在、私は「完了」、「編集」を作成し、私はボタンの機能を「コールバック」は、いわゆるとしてこれらの3を持っている編集操作が削除かUITableViewControllerで追加するかを確認する
- (void)initializeNavigationBarButtons
{
UIBarButtonItem *newEditButton =
[[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemEdit
target:self action:@selector(performEdit:)];
self.editButton = newEditButton;
[newEditButton release];
self.navigationItem.rightBarButtonItem = self.editButton;
UIBarButtonItem *newDoneButton =
[[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self action:@selector(performDone:)];
self.doneButton = newDoneButton;
[newDoneButton release];
UIBarButtonItem *newAddButton =
[[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
target:self action:@selector(performAdd:)];
self.addButton = newAddButton;
[newAddButton release];
self.navigationItem.leftBarButtonItem = self.addButton;
}
ボタンを「追加」するには、このコードを持っている:
- (void)performDone:(id)paramSender
{
[self.tableView setEditing:NO animated:YES];
[self.navigationItem setRightBarButtonItem:self.editButton
animated:YES];
[self.navigationItem setLeftBarButtonItem:self.addButton
animated:YES];
}
- (void)performEdit:(id)paramSender
{
NSLog(@"Callback Called");
[self.tableView setEditing:YES animated:YES];
[self.navigationItem setRightBarButtonItem:self.doneButton
animated:YES];
[self.navigationItem setLeftBarButtonItem:self.doneButton
animated:YES];
}
- (void)performAdd:(id)paramSender
{
[self.tableView setEditing:YES animated:YES];
[self.navigationItem setRightBarButtonItem:self.doneButton
animated:YES];
[self.navigationItem setLeftBarButtonItem:self.doneButton
animated:YES];
}
と、ここで私はそれがアドオンであるかどうかを決定するか、または操作を削除「することになって」AMところです:私はself.isDeletingとself.isAddingを設定することが出来るのですどこ
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView
editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *output = (isDeleting) ? @"Deleting" : @"Adding";
NSLog(@"%@", output);
UITableViewCellEditingStyle result = UITableViewCellEditingStyleNone;
if ([tableView isEqual:self.tableView]){
if (self.isDeleting == YES){
result = UITableViewCellEditingStyleDelete;
}
else{
result = UITableViewCellEditingStyleInsert;
}
}
return result;
}
しかし、私は知りません。コールバックでそれらを設定しようとしましたが、tableView:cellEditingStyleForRowAtIndexPath:が最初に呼び出され、私のviewDidLoadのデフォルト値はNOです。
したがって、tableView:cellEditingStyleForRowAtIndexPath:メソッドで適切に動作するように、isAddingおよびisDeletingの値を適切に設定するにはどうすればよいですか?
ありがとうございます!