天天看点

Ios 6和ios7的适配Ios 6和ios7的适配Ios6 和ios7屏幕翻转

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 出现视图看不到的情况