首页 新闻 会员 周边

怎样在ViewController里监听xib里的按钮点击(不用连线的方法)

0
悬赏园豆:5 [已解决问题] 解决于 2014-12-24 16:10

如题

新建一个xib,添加一个toolBar,增添两个UIBarButtonItem分别命名为上移,下移

然后怎么在ViewController里监听这两个按钮点击啊

要求:不能用连线的方法监听按钮点击(以免造成高耦合性)

_singer的主页 _singer | 初学一级 | 园豆:197
提问于:2014-12-19 19:48
< >
分享
最佳答案
1

- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

 

    //Add button to NavigationController

    UIBarButtonItem *backButton =

    [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"back", @"")

                                     style:UIBarButtonItemStylePlain

                                    target:self

                                    action:@selector(goBack)];

    

    self.navigationItem.leftBarButtonItem = backButton;

    

  

}

//Perform action on back Button

- (void) goBack {    // Go back task over-here

}

设置action?

收获园豆:5
Alex Wei | 菜鸟二级 |园豆:245 | 2014-12-20 01:05
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册