如何以编程方式获取iPhone屏幕尺寸? [英] How to get iPhone screen size programmatically?

查看:152
本文介绍了如何以编程方式获取iPhone屏幕尺寸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
如何使用代码获取屏幕尺寸?

Possible Duplicate:
How to get screen size using code?

 NSLog(@"Top Left View : Width %f height%f",self.topLeftView.frame.size.width,self.topLeftView.frame.size.height);

我已经从对象库中拖动了视图"并将其放在xib文件中.

I have dragged the "View" from object library and put it on xib file.

但是,如果我想获取屏幕尺寸以检查其iPhone 4,iPhone 3或iPhone 5或任何iOS设备该怎么办?

But what if I want to get the screen size to check whether its iphone 4,iPhone 3 or iphone 5 or any iOS Device.

以便我可以相应地安排其他视图.

So that I can arrange other views accordingly.

推荐答案

您可以使用:

CGsize screenSize      = [[[UIScreen mainScreen] bounds] size];
CGFloat widthOfScreen  = screenSize.width;
CGFloat heightOfScreen = screenSize.height;

这篇关于如何以编程方式获取iPhone屏幕尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆