开发者

Changing the size of UIScreen on rotation

开发者 https://www.devze.com 2023-03-18 20:29 出处:网络
I am making an iPad app that 开发者_如何学JAVAstarts out in the portrait orientation but can rotate over to the landscape orientation. In -(void) loadView, I call the function drawView. In drawView, I

I am making an iPad app that 开发者_如何学JAVAstarts out in the portrait orientation but can rotate over to the landscape orientation. In -(void) loadView, I call the function drawView. In drawView, I have this line of code:

CGRect r = [[UIScreen mainScreen] bounds];

The only problem is that it doesn't update itself when I rotate to landscape mode, so it still thinks that the screen is in the vertical orientation and if I want a text view to extend all the across the entire screen, it cuts it off at the 768th pixel, instead of the 1024th pixel. In -(BOOL)shouldAutorotate... I have case UIInterfaceOrientationLandscapeRight: and case UIInterfaceOrientationLandscapeLeft:, and I would have to ideally place CGRect r = [[UIScreen mainScreen] bounds]; under each case, but I don't think that will work. Any suggestions? Thanks for your help!

Edit: I've even tried calling a function with

CGRect r = [[UIScreen mainScreen] bounds];

in it, but it still won't work. I place an NSLog after it and I received a response, so the app is definitely working properly and not crashing, but I am still unable to figure this out. Any ideas? Thanks for your help!


I think your problem could be solved by using the autoresizingMask of UIView;


Does your app happen to rely on plists for configuration? I've seen some apps where you can get landscape but only after you set an orientation key to false.

0

精彩评论

暂无评论...
验证码 换一张
取 消