[英]Force iOS interface orientation
我可以通過幾種技巧來更改旋轉方式(例如,調用[[UIDevice currentDevice] setValue:rotation forKey:@"orientation"];
或呈現一個UIViewController
,其中覆蓋了所需的旋轉方法,並在不久后將其關閉)。
問題是 ,當我在不支持該功能的UIViewController
中禁用手機上的旋轉鎖定並將其旋轉至所需的旋轉方式時,然后轉到支持該旋轉的UIViewController
(通過彈出窗口),旋轉未正確應用。
任何想法如何解決這個問題?
我想我了解您的要求,而且我以前也遇到過這個問題。 我通過將其放入正在彈出的視圖控制器中來解決:
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
[[UIDevice currentDevice]performSelector:@selector(setOrientation:) withObject:(__bridge id)((void *)UIInterfaceOrientationPortrait)];
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.