自定义导航返回按钮是用customView不可以的原因?
来源:互联网 发布:广州行知职高 编辑:程序博客网 时间:2024/05/16 18:48
1、自定义返回按钮时,在父控制器viewController中如下设置:
UIBarButtonItem *backbutton = [[UIBarButtonItem alloc]init]; backbutton.title = @"返回列表"; self.navigationItem.backBarButtonItem = backbutton;
2、当我们在创建UIBarButtonItem时,如果这样创建是没有效果的:
UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];[btn setTitle:@"哈哈" forState:UIControlStateNormal];btn.frame = CGRectMake(0, 0, 40, 30);UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:btn];self.navigationItem.backBarButtonItem = backItem;[self.navigationController pushViewController:_testVC animated:YES];
为什么用[[UIBarButtonItem alloc] initWithCustomView:btn]创建不可以呢?查阅苹果官方文档说明:
Initializes a new item using the specified custom view.
The bar button item created by this method does not call the action method of its target in response to user interactions. Instead, the bar button item expects the specified custom view to handle any user interactions and provide an appropriate response.
原来此方法无法定义的UIBarButtonItem不能响应交互,就是用此方法创建的UIBarButtonItem会导致push过去的的backItem不能返回,所以苹果不允许在父控制器viewController中这样创建UIBarButtonItem来设置返回按钮;
0 0
- 自定义导航返回按钮是用customView不可以的原因?
- 自定义导航返回按钮
- 自定义导航栏上的返回按钮
- 自定义导航栏上的返回按钮
- iOS自定义导航栏的返回按钮
- iOS 自定义导航栏的返回按钮
- 自定义导航栏的返回按钮
- 自定义导航栏的返回按钮
- 定制iOS 7中的导航栏和状态栏(主要是自定义的返回按钮)
- 自定义导航条返回按钮
- 自定义导航栏返回按钮
- 自定义导航控制器返回按钮
- 自定义导航栏返回按钮
- 自定义导航栏返回按钮
- 自定义默认生成的导航栏 标题 颜色 返回按钮
- 自定义导航栏返回按钮backBarButtonItem的标题
- 自定义导航条时返回按钮失效的问题
- 自定义导航栏返回按钮文字
- android developer tiny share-20170208
- ionic应用图标不能正常显示解决办法
- GitLab: No such project
- 利用Java反射实现JavaBean对象相同属性复制并初始化目标对象为空的属性的BeanUtils
- 性能优化-基于sqlite的优化
- 自定义导航返回按钮是用customView不可以的原因?
- 238. Product of Array Except Self (后两种方法有待进一步研究)
- poj1741 Tree
- PHP面向对象——构造函数、析构函数
- 触摸事件的分发与处理
- ML 工程师需了解的 10 大算法
- Git修改已经提交的注释
- 打印错误的堆栈信息
- 更为详细的Txtsetup.sif文件解释