通常iOS开发中会自定义Tab,跳转时通常会使如下代码直接跳转:
LZHTabBarController *tabVC = [[LZHTabBarController alloc]init];
[UIApplication sharedApplication].delegate.window.rootViewController = tabVC;
这个时候Xcode会警告Unbalancedcalls tobegin/endappearance transitionsfor<TabBarController:0x160806c00>.
原因就是控制器跳转时动画未结束就立马进行下一步,解决方法就是通过GCD延时让动画先结束再跳转,代码如下:
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
LZHTabBarController *tabVC = [[LZHTabBarController alloc]init];
[UIApplication sharedApplication].delegate.window.rootViewController = tabVC;
});
建议延时最低0.1s,保证动画能够结束,太长会影响跳转视觉效果
同时也可在自定义的Tab中添加如下代码预防问题:
网友评论