右栏按钮项目不起作用
实际上我在导航栏的右侧放置了一个栏按钮,但它不起作用。但是当我将它用作左栏按钮项目时,它工作正常。我用的是ios5。
当我同时拥有左栏按钮和右栏按钮时,它也不起作用。然后我为两者设置了框架,然后这些就可以工作了。但是当我的右侧只有一个按钮时,它不起作用。
UIButton *but1 = [UIButton buttonWithType:UIButtonTypeCustom];//customising map button.
but1.frame = CGRectMake(270,0,50,40);
[but1 addTarget:self action:@selector(clicked) forControlEvents:UIControlEventTouchUpInside];//on cilcking an map button clicked method is called.
buttonRight = [[UIBarButtonItem alloc]initWithCustomView:but1];//setting map button on Navigation bar.
self.navigationItem.rightBarButtonItem = buttonRight;//setting button on the Right of navigation bar.
如何追踪这个错误?
Actually i am placing a bar button on right side of navigation bar, it's not working. But when i use it as left bar button item, it's working fine. I am using ios5.
It was also not working when i have both button left and right bar button. Then i set the frame for both, then these are working. But when i have only one button on right side, it's not working.
UIButton *but1 = [UIButton buttonWithType:UIButtonTypeCustom];//customising map button.
but1.frame = CGRectMake(270,0,50,40);
[but1 addTarget:self action:@selector(clicked) forControlEvents:UIControlEventTouchUpInside];//on cilcking an map button clicked method is called.
buttonRight = [[UIBarButtonItem alloc]initWithCustomView:but1];//setting map button on Navigation bar.
self.navigationItem.rightBarButtonItem = buttonRight;//setting button on the Right of navigation bar.
how to trace out this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于 Swift 4.2 代码:
在视图中加载函数
函数定义如下:
For Swift 4.2 code:
In the View did load function
Function definition goes here: