实名认证身份证照片我的格式也对 大小也对 为什么选不了 传不上去?
简单的办法:
- (CGRect)getScreenFrameForCurrentOrientation {
return [self getScreenFrameForOrientation:[UIApplication sharedApplication].statusBarOrientation];
}
- (CGRect)getScreenFrameForOrientation:(UIInterfaceOrientation)orientation {
CGRect fullScreenRect = [[UIScreen mainScreen] bounds];
// implicitly in Portrait orientation.
if (UIInterfaceOrientationIsLandscape(orientation)) {
CGRect temp = CGRectZero;
temp.size.width = fullScreenRect.size.height;
temp.size.height = fullScreenRect.size.width;
fullScreenRect = temp;
}
if (![[UIApplication sharedApplication] statusBarHidden]) {
CGFloat statusBarHeight = 20; // Needs a better solution, FYI statusBarFrame reports wrong in some cases..
fullScreenRect.size.height -= statusBarHeight;
}
return fullScreenRect;
}
你需要依据视图大小来匹配屏幕大小,正如您所看到的,情况并非总是如此。如果您需要屏幕大小,您应该查看代表屏幕本身的对象,如下所示:
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;
更新分割视图:在评论中,德米特里问道:
如何在分割视图中获得屏幕大小?
上面给出的代码报告了屏幕的大小,即使在分屏模式下也是如此。当你使用分屏模式时,你的应用程序的窗口会改变。如果上面的代码没有给你所期望的信息,那么就像OP一样,你正在看错误的对象。在这种情况下,你应该看看窗口而不是屏幕,就像这样:
CGRect windowRect = self.view.window.frame;
CGFloat windowWidth = windowRect.size.width;
CGFloat windowHeight = windowRect.size.height;
相似问题