How to autorotate from portrait to landscape mode?

感情迁移 提交于 2019-12-31 06:57:52

问题


How can I autorotate an image from portrait to landscape mode on the IPhone?


回答1:


If you want to display a new and different view, the simplest and cleanest solution is to push a new view controller (presentModalViewController) that only supports landscape mode (in shouldAutorotateToInterfaceOrientation:).




回答2:


You have to implement shouldAutorotateToInterfaceOrientation method in your controller, like this

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}



回答3:


Apply proper transformation to the view and adjust its frame bounds

In my app I've done it this way (very likely not the best one):

[UIView beginAnimations:@"View Flip" context:nil];
[UIView setAnimationDuration: 0.5f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

self.view.transform = CGAffineTransformIdentity;
self.view.transform = CGAffineTransformMakeRotation(-M_PI/2);
self.view.bounds = CGRectMake(0.0f, 0.0f, 480.0f, 320.0f);

self.view.center = CGPointMake(160.0f, 240.0f);
[UIView commitAnimations];


来源:https://stackoverflow.com/questions/1437636/how-to-autorotate-from-portrait-to-landscape-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!