0
私はこの質問が数回答えられたかもしれないことは知っていますが、文字通りStackOverflowで見つけられる可能性のあるものをすべて試しました。プログラムでUIInterfaceOrientationMaskLandscapeLeftにビューのサイズを変更
基本的に、私はそうのように初期化するカスタムUIViewのクラスがあります。そして、
MyUIView *test = [[MyUIView alloc] initWithFrame:self.view.bounds];
を、私はNSTimerこの呼び出しで5秒でオフに行くようにスケジュールしている:どの基本的に
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
if (!self.isRotated) {
self.isRotated = YES;
appDelegate.allowLandscape = YES;
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger: UIInterfaceOrientationLandscapeLeft] forKey:@"orientation"];
}else{
self.isRotated = NO;
appDelegate.allowLandscape = NO;
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger: UIInterfaceOrientationPortrait] forKey:@"orientation"];
}
い:
-(UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
if (self.allowLandscape) {
return UIInterfaceOrientationMaskLandscapeLeft;
}else{
return UIInterfaceOrientationMaskPortrait;
}
}
そして私はちょうどにself.allowLandscape
を設定した場合、それが正常に動作します方法の。しかし、5秒後にNSTimerメソッドを呼び出すと、UIViewはLandscapeLeft
に変換されません。
私はおそらく制約を使ってこの問題を解決できましたが、このプロジェクトではプログラマチックサイズのみを使用しています。
ちょうど試してみましたが、何もしませんでした.. –