我正在实施commitEditingStyle:
。当我点击导航栏上的编辑按钮滑动删除按钮将到达,一切正常。
问题是当我点击“编辑”时我想将该按钮更改为“完成”,当我点击“完成”时,表格视图单元格上的删除按钮应该消失,我该怎么办呢我是新手请指导我在哪里犯了错误。
代码段如下所示: -
- (void)viewDidLoad
{
UIToolbar* tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 133, 44.01)];
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:3];
UIBarButtonItem* bi = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(ComposeBtn)];
bi.style = UIBarButtonItemStyleBordered;
[buttons addObject:bi];
[bi release];
bi = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
[buttons addObject:bi];
[bi release];
bi = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(setEditing:)];
bi.style = UIBarButtonItemStyleBordered;
[buttons addObject:bi];
[bi release];
[tools setItems:buttons animated:NO];
[buttons release];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tools];
[tools release];
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
return YES;
}
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
[super setEditing:editing animated:animated];
[self.listOfFilesTblView setEditing:editing animated:animated];
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleDelete;
}
如果我使用下面的代码行,evrything工作正常。
self.navigationItem.rightBarButtonItem=self.editButtonItem;
但是我想要导航栏上的2个按钮,1)编辑2)撰写。 请指导我在这里缺少的东西。谢谢。