Avoid hardcoding iPhone screen size with programmatic view creation

Posted by miorel on Stack Overflow See other posts from Stack Overflow or by miorel
Published on 2010-03-27T19:33:31Z Indexed on 2010/03/27 19:53 UTC
Read the original article Hit count: 478

Hi,

I was looking up how to create a view programmatically and found the following example code:

self.view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];

This works great, except I don't like that it hardcodes the size of the screen. Is there a way to look up the size of the screen? An important point someone brought up is that if the app is running during a phone call then the screen will be slightly smaller because of the green "return to call" bar.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk