Ios 6和ios7的適配
1.普通的 ViewController:讓view的顯示從狀態欄下面開始,只需在viewDidLayoutSubviews調整 view的bounds
CGRect bounds = self.view.bounds;
bounds.origin.y = - [self.topLayoutGuide length];
self.view.bounds = bounds;
2.ScrollView 類型的 在viewDidLoad 裏面加:
if ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0) {
self.tableView.contentInset = UIEdgeInsetsMake(20, 0, 0, 0);
}
3.有導航控制器的普通ViewController:在viewDidLoad裏面加
#ifdef __IPHONE_7_0
if ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
#endif
4.有導航控制器的UITableViewController不用適配,他會自動在導航控制器的下面
5.有選項卡的ViewController:在ViewDidLoad裏面加:
#ifdef __IPHONE_7_0
if ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
#endif
6.有選項卡的UITableViewController在ViewDidLoad裏面加:
#ifdef __IPHONE_7_0
if ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0) {
self.edgesForExtendedLayout = UIRectEdgeNone;
self.tableView.contentInset = UIEdgeInsetsMake(20, 0, 0, 0);
}
#endif
7.有導航控制器和有選項卡的UITableViewController不用適配,他會自動在2者的中間
8.有導航控制器和有選項卡的ViewController不用適配,他會自動在2者的中間
Ios6 和ios7屏幕翻轉
1.在UIViewController裏面添加
- (BOOL)shouldAutorotate{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortraitUpsideDown;
}
設置方向後不是真正顯示的UIViewController presentViewController 出現視圖看不到的情況