如何在导航栏中使用右侧导航按钮设置自定义方法
我想使用 RightNavagation 按钮设置我的自定义方法“Home”,我该怎么办? 我的代码
UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithTitle:@"DontWorryAboutThis" style:UIBarButtonItemStylePlain target:self action:@selector(home:)];
[barButton setImage:[UIImage imageNamed:@"home_btn.png"]];
[self.navigationItem setRightBarButtonItem:barButton];
知道我想将此方法与其链接。
-(IBAction)home{
MainViewController *main=[[MainViewController alloc]
initWithNibName:@"MainViewController" bundle:nil];
[self.navigationController pushViewController:main animated:YES];
}
我应该怎么做,请帮助我。
I want set my custom method "Home" with RightNavagation button how should I?
My code
UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithTitle:@"DontWorryAboutThis" style:UIBarButtonItemStylePlain target:self action:@selector(home:)];
[barButton setImage:[UIImage imageNamed:@"home_btn.png"]];
[self.navigationItem setRightBarButtonItem:barButton];
Know I want to link this method with it.
-(IBAction)home{
MainViewController *main=[[MainViewController alloc]
initWithNibName:@"MainViewController" bundle:nil];
[self.navigationController pushViewController:main animated:YES];
}
how should I Do this please help me out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试
改变
Try to change
in
将您的选择器 @selector(home:) 与您的操作进行比较 -(IBAction)home
看到操作中缺少的冒号吗?
将你的动作改为
compare your selector @selector(home:) with your action -(IBAction)home
See the missing colon in your action?
Change your action to