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 出現視圖看不到的情況