1.全部的UIViewController加以下方法。
- (void) viewDidLayoutSubviews {
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0){
CGRect viewBounds = self.view.bounds;
CGFloat topBarOffset = self.topLayoutGuide.length;
viewBounds.origin.y = topBarOffset * -1;
self.view.bounds = viewBounds;
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
}
在项目的plist文件里加View controller-based status bar appearance,值为no
2.scrollerView报错,找不到setAutomaticallyAdjustsScrollViewInsets:方法,解决方法
重写方法setAutomaticallyAdjustsScrollViewInsets:
- (void)setAutomaticallyAdjustsScrollViewInsets:(BOOL)automaticallyAdjustsScrollViewInsetsios
{app
if(IS_IOS7){ide
[super setAutomaticallyAdjustsScrollViewInsets:automaticallyAdjustsScrollViewInsets];ui
}spa
}.net
而后viewDidLoad里面加上:
if([self respondsToSelector:@selector(setAutomaticallyAdjustsScrollViewInsets:)]){
self.automaticallyAdjustsScrollViewInsets = NO;
}
3.再作ios7兼容的时候最好让全部的UIViewController继承一个本身定义的UIViewController,而后好统一管理。
4.UITableView cell的分割线不能靠左的解决方法
添加一句:
[UITableViewappearance].separatorInset=UIEdgeInsetsZero;
5.适配IOS7时使用edgesForExtendedLayout遇到的问题
代码是navigationBar+tabBar组成的
在viewDidLoad里加了以下代码,
if([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
{
self.edgesForExtendedLayout = UIRectEdgeNone;
self.extendedLayoutIncludesOpaqueBars = NO;
self.modalPresentationCapturesStatusBarAppearance = NO;
self.navigationController.navigationBar.barTintColor =[UIColor grayColor];
self.tabBarController.tabBar.barTintColor =[UIColor grayColor];
}
加了以后UI显示正常了,即没有上移20的高度。
问题是,当运行程序,自动进入到tabBar对应的第一个页面时,navigationBar和tabBar会出现黑色的背景,一小会会消失,才变成本身设置的背景色。
若是注释掉上面代码,进入程序时不会出现黑色背景,可是里面的UI会上移20的高度...
解决方法:
self.navigationController.navigationBar.translucent = NO; self.tabBarController.tabBar.translucent = NO;
copy from http://blog.csdn.net/yongyinmg/article/details/23861853