2013-03-12 58 views
0

是否有一种方法可以覆盖tableView中的UIBarButtons功能?覆盖UIBarButtons在tableView中的功能

- (IBAction)addNewBook:(UIBarButtonItem *)sender { 

    [self performSegueWithIdentifier:@"addNewBook" sender:self]; 

} 

- (IBAction)myBooks:(UIBarButtonItem *)sender { 
    [self performSegueWithIdentifier:@"myBooks" sender:self]; 
} 

我这两个UIBarButtons取得了新的动作(查看表),并尝试添加塞格斯去新viewControllers当按下这些按钮,但这些UIBarButtons已经预先确定的功能 - 对一个人的功能添加,左边是删除。有没有办法来重写这些函数 - 所以我可以得到我想要发生的segues,而不是删除和添加列表中的东西?

+0

你想执行这两个功能吗?预定和新的?我的意思是在两种不同的情况下 – 2013-03-12 03:37:29

回答

1

只需将您的barItem拖动到storyBoard中的NavigationBar并拖动继续。 然后删除这些代码,编辑并添加不是默认按钮,它们设置在viewDidLoad中。

self.navigationItem.leftBarButtonItem = self.editButtonItem; 

UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject:)]; 
self.navigationItem.rightBarButtonItem = addButton; 
+0

非常感谢你! – coolcool1994 2013-03-12 03:38:44