先说LeftBarButtonItem
项目的NAV结构略复杂,首页是一个nav,然后push到一个tabbar是四个nav
在tabbar里加入系统返回手势,在tabbar那里左侧边缘右滑会有莫名其妙的bug出现。
解决方法如下:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
/**
* 侧边滑动效果
*/
NSArray *arr = self.navigationController.viewControllers;
if (arr.count <= 1) {
//不加返回
self.navigationController.interactivePopGestureRecognizer.delegate = nil;
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
else
{
//加返回
self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
}
-(void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
//ios7返回手势
if (IOS7_OR_LATER) {
//(左滑返回)代理置空,否则会闪退
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.delegate = nil;
}
}
//delegate
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
//开启滑动手势
if ([navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
navigationController.interactivePopGestureRecognizer.enabled = YES;
}
}
这么搞就没bug了。。
然后是关于scrollToTop的
我在一个页面的tableView,scrollToTop不生效,然后我一个个看这个VC的subView,结果发现,一个textView的默认属性,是scrollToTop = YES;我和我的小伙伴都惊呆了。。。。
碎碎念一下,项目的下个版本,应该就不支持IOS6了,我决定撒花庆祝下。
简书已经弃用,欢迎移步我的小专栏:
https://xiaozhuanlan.com/dahuihuiiOS
网友评论