iPhoneシミュレーターとiPhone3GS(iOS 6)の両方で、向きを逆さまに縦向きに設定することができません。ViewControllerは1つだけです。私はそれにこのコードを追加しました:
-(BOOL) shouldAutorotate{
return YES;
}
-(UIInterfaceOrientation) preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationPortraitUpsideDown;
}
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationPortrait | UIInterfaceOrientationPortraitUpsideDown;
}
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
if (toInterfaceOrientation==UIInterfaceOrientationPortrait || toInterfaceOrientation==UIInterfaceOrientationPortraitUpsideDown) {
return YES;
}
return NO;
}
これもAppDelegate.mに追加しました。
-(NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
return UIInterfaceOrientationPortrait | UIInterfaceOrientationPortraitUpsideDown;
}
plistファイルも確認しましたが、両方の方向がそこにあります。私のストーリーボードでは、シミュレートされたメトリックで方向が推定に設定されています。YESを返す以外は、applicationDidFinishLaunchingWithOptionsでは何もしません。このViewController内にUIImageViewを追加しました。このオリエンテーションを機能させることは可能ですか?