change return from shouldAutorotateToInterfaceOrientation: at runTime

╄→尐↘猪︶ㄣ 提交于 2019-12-23 05:19:08

问题


I'm using shouldAutorotateToInterfaceOrientation: for respond YES to all orientations.

At runtime, in few case, i must change the return to YES only in portrait.

But if i change this return type, and my device not physicly turn, my interface orientation not change. How can it's possible to force uiView to check the shouldAutorotateToInterfaceOrientation: and rotate the view without UIdevice rotation notification.

Thanks a lot.


回答1:


Add this two lines of code:

    [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];



回答2:


Static method starting from IOS 5:
[UIViewController attemptRotationToDeviceOrientation];



来源:https://stackoverflow.com/questions/6518961/change-return-from-shouldautorotatetointerfaceorientation-at-runtime

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