iOS8全屏视图被切断

时间:2014-11-30 14:46:20

标签: ios ios7 ios8

在iOS7中,我可以使用以下代码创建全屏视图:

- (void)loadView {
    CGSize screenSize = [UIScreen mainScreen].bounds.size;
    CGRect frame = CGRectMake(0, 0, screenSize.height, screenSize.width);
    UIView *view = [[UIView alloc] initWithFrame: frame];

    self.view = view;
}

当移动到iOS8时,此代码无法正常工作,屏幕被切断并在右侧缩放,类似于:

---------------   ---------------   
|             |   |         |   |
|     iOS7    |   | iOS8    |   |
| Full Screen |   | Cut Off |   |
|             |   |         |   |
|             |   |         |   |
---------------   ---------------

这会影响我的应用中以编程方式生成的所有全屏视图,这里有任何想法吗?

1 个答案:

答案 0 :(得分:0)

而不是:

CGRect frame = CGRectMake(0, 0, screenSize.height, screenSize.width);

你需要

CGRect frame = CGRectMake(0, 0, screenSize.width, screenSize.height);

及其:

CGRect CGRectMake ( CGFloat x, CGFloat y, CGFloat width, CGFloat height );