我们在Coding的时候,肯定会遇到各式各类的bug,按着以往的经验来说,适当汇总一些还是有必要的。
以下是我最近遇到的,但是这也会慢慢增加中...
1、这是升级iOS 9 之后遇到的一个常见问题
This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release.
解决方法加了个
dispatch_async(dispatch_get_main_queue(), ^{
// 更UI
});
2、第二个 与UICollectionViewFlowLayout有点关的
the behavior of the UICollectionViewFlowLayout is not defined because:the item height must be less that the height of the UICollectionView minus the section insets top and bottom values.
解决的方法
self.automaticallyAdjustsScrollViewInsets = NO;
但是上面那个问题,如果是在设置 UIAlertController的时候弹出的话
2015-10-20 22:38:54.007 TestApp[3128:48601] the behavior of the UICollectionViewFlowLayout is not defined because:
2015-10-20 22:38:54.008 TestApp[3128:48601] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
2015-10-20 22:38:54.008 TestApp[3128:48601] The relevant UICollectionViewFlowLayout instance is <_UIAlertControllerCollectionViewFlowLayout: 0x7fd6b8582d90>, and it is attached to ; layer = ; contentOffset: {0, 0}; contentSize: {0, 0}> collection view layout: <_UIAlertControllerCollectionViewFlowLayout: 0x7fd6b8582d90>.
解决方法就需要另外设置啦,待定
3、有时候在用presentViewController跳转的时候
Warning: whose view is not in the window hierarchy!
经调查原因是:大意就是页面跳转必须在viewDidLoad和viewDidAppear之后才能进行
解决的方法
方法一,延长时间跳转,不可取,应为不知道什么时间进行跳转
方法二:[selfperformSelectorOnMainThread:@selector(login)withObject:nilwaitUntilDone:NO];
把页面跳转的代码写进函数里,然后将 waitUntilDone 设为NO,就是viewDidLoad直接返回不用等login执行。这样就可以确保login里的页面跳转是在viewDidLoad之后执行。
方法三,也是另一种情况,就是跳转的时候还有其他操作需要进行
[self presentViewController:loginVC animated:NO completion:^{[loginVC auth:BAIDU_API_KEY secret:nil disk:BAIDU];}];
方法四,我自己特殊的情况,以上三种都不没解决我的问题
于是我就不用presentViewController这种方法啦,改变思路,哈哈哈