在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 | |
| | | | |
| | | | |
--------------- ---------------
这会影响我的应用中以编程方式生成的所有全屏视图,这里有任何想法吗?
答案 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 );