报错/警告提示

警报:

1. <Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.

  出错原因:设置app的状态栏样式的使用使用了旧的方式,在info.plist里面设置了View controller-based status bar appearance为NO,默认为YES,一般式iOS6的时候使用这种方式,iOS7,8也兼容,但是到了iOS9就报了警告。

  解决办法:

删除 原先的设置代码 

//设置状态栏的白色
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

修改方式将View controller-based status bar appearance设置为YES,然后使用新的方式来实现状态栏的样式。

在你的 自定义导航控制器里面 写上如下方法:

//设置状态栏的(亮色)白色
-(UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleLightContent;
}

记住要clean 或者删除应用程序 重新运行

2.在导航控制器下用UICollectionViewController时,设置flowLayout的itemWidth时,报错the item height must be less than the height of the UICollectionView minus thesection insets top and bottom values.

方法1:

    CGSize screenSize = [UIScreen mainScreen].bounds.size; // 这里的高度应该减去导航条的高度和状态栏的高度,而不是屏幕的高度!
    self.layout.itemSize = CGSizeMake(screenSize.width, screenSize.height - CYNavigationBarHeight - CYStatusBarHeight);

方法2:

self.automaticallyAdjustsScrollViewInsets = NO;
原文地址:https://www.cnblogs.com/jiayongqiang/p/5669661.html