以下是我在项目中实践所得,兼容iPhone5,满足目前的项目要求。
/**
手工构建视图,兼容iPhone5的做法:
1、获取控制器视图的位置大小bounds,如果有顶部导航栏,高减44;如果有底部导航栏,高减49;
2、使用bounds构建自定义视图,添加到控制器视图里面。
*/
- (void)loadView {
[super loadView];
CGRect bounds = self.view.bounds;// 控制器的视图的位置大小
bounds.size.height -= 44;// 如果有顶部导航栏,高减44
bounds.size.height -= 49;// 如果有底部导航栏,高减49
// 添加自定义视图,使用|bounds|作为|frame|
// CustomView customView = [[[CustomView alloc] initWithFrame:bounds] autorelease];
// [self.view addSubview:customView];
}
推荐文章:http://www.raywenderlich.com/33150/how-to-update-your-apps-for-the-4-inch-iphone-5-display