uiscreen

How to get iPhone screen size programmatically? [duplicate]

此生再无相见时 提交于 2019-12-20 19:36:14
问题 This question already has answers here : Closed 6 years ago . 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); I have dragged the "View" from object library and put it on xib file. 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. 回答1: You can use: CGsize screenSize =

How to get screen size using code on iOS?

元气小坏坏 提交于 2019-12-17 15:23:14
问题 How to get the iPhone screen size to give calculation? 回答1: You can use the bounds property on an instance of UIScreen: CGRect screenBound = [[UIScreen mainScreen] bounds]; CGSize screenSize = screenBound.size; CGFloat screenWidth = screenSize.width; CGFloat screenHeight = screenSize.height; Most people will want the main screen; if you have a device attached to a TV, you may instead want to iterate over UIScreens and get the bounds for each. More info at the UIScreen class docs. 回答2: Here is

UIScreen MainScreen Bounds returning wrong size

安稳与你 提交于 2019-12-17 07:20:09
问题 So I created a new project with the latest version of XCode and tried to log the screen size of my app (to determine the device type for UI). I ran the following code from my iPhone 5: NSLog(@"%f", [[UIScreen mainScreen] bounds].size.height); This returned 480 , which is the screen size for the old iPhone family. I tried in the simulator and the same thing happened. Is there some property I have to enable in the project for it to recognize the screen size? This only happens for 5+ devices; if

Detect Retina Display

与世无争的帅哥 提交于 2019-12-17 02:25:34
问题 Does iOS SDK provides an easy way to check if the currentDevice has an high-resolution display (retina) ? The best way I've found to do it now is : if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] == YES && [[UIScreen mainScreen] scale] == 2.00) { // RETINA DISPLAY } 回答1: In order to detect the Retina display reliably on all iOS devices, you need to check if the device is running iOS4+ and if the [UIScreen mainScreen].scale property is equal to 2.0. You CANNOT assume a device

[UIScreen mainScreen].bounds vs [UIApplcation sharedApplication].keyWindow.bounds?

余生长醉 提交于 2019-12-14 03:48:05
问题 I have view that i want to cover entire screen. And i want to set its frame to cover entire screen. Browsing the stack overflow i found these two different ways of setting view frame to cover the screen: [UIScreen mainScreen].bounds [UIApplcation sharedApplication].keyWindow.bounds It seems to me they are returning same values always, or at least in few test cases I have tried. Currently i am using UIScreen , but i curious to know difference between these calls? Will there be some cases where

On iOS, can we get to the main UIWindow object from the UIScreen object?

让人想犯罪 __ 提交于 2019-12-13 20:07:35
问题 Say, if we already have aScreen that points to the main screen, by UIScreen *aScreen = [UIScreen mainScreen]; can we get to the main UIWindow object from this UIScreen object? (do they have any connection at all? That is, instead of using [UIApplication sharedApplication].keyWindow ) 回答1: No. The application has a list of windows, usually just one. Each window has a screen property that indicates where it's currently located. The screen object holds information about the physical device. It

Can a gesture recogniser control iOS display brightness?

馋奶兔 提交于 2019-12-13 03:16:21
问题 I'd like to let the user control the brightness in an iOS app using a gesture recogniser to swipe up and down. Can gestures even control brightness? I've done it before using a slider and the brightness property of UIScreen... [UIScreen mainScreen].brightness = 0.5; I want to be able to control the brightness as you would with a slider (like the iBooks app) but instead of a slider use a gesture recogniser. The idea is that the gesture continuously changes the brightness value as long as a

Possible crash when loadNibNamed on jailbreak devices [UIDeviceRGBColor superview]: unrecognized selector

两盒软妹~` 提交于 2019-12-08 02:25:39
问题 My code looks like this: CGRect screenRect = [[UIScreen mainScreen] bounds]; SomeView *infoView; if(screenRect.size.height != 568.0){ // iPhone 5/5s users crash in the next line infoView = [[[NSBundle mainBundle] loadNibNamed:@"SomeViews" owner:self options:nil] objectAtIndex:1]; }else{ infoView = [[[NSBundle mainBundle] loadNibNamed:@"SomeViews" owner:self options:nil] objectAtIndex:0] } However, I get some crash reports from Crashlytics for iPhone 5/5s users as comment in the above code. I

iOS: Programmatically creating UIWindow results in wrong position

為{幸葍}努か 提交于 2019-12-07 06:10:45
问题 In iOS 5.1.1, I have found that if I create my UIWindow (I'm tired of IB), and set its frame to [UIScreen mainScreen].bounds, the window shows up under the status bar . However if I do the same thing is iOS 6, it appears in the right spot just below the status bar. CGRect r = [[UIScreen mainScreen] bounds]; self.window = [[UIWindow alloc] initWithFrame: r]; self.detailViewController = [[DetailViewController alloc] init]; self.window.rootViewController = self.detailViewController; [self.window

Setting UIScreen's mode / resolution

丶灬走出姿态 提交于 2019-12-06 11:36:19
问题 I have to set the external UIScreen's mode to run with the resolution 1024x768. First I search if the screen supports this resolution: if ([[UIScreen screens] count] > 1){ CGSize size1024; size1024.height = 0; size1024.width = 0; UIScreenMode *screenMode1024 = nil; UIScreen *secondScreen = [[UIScreen screens] objectAtIndex:1]; for(int i = 0; i < [[secondScreen availableModes] count]; i++) { UIScreenMode *current = [[[[UIScreen screens] objectAtIndex:1] availableModes] objectAtIndex: i]; if