1

さまざまなビュー コントローラーを備えた cuople のビューを持つアプリがあります。1 つはマップ ビューで、もう 1 つはポートレート/ランドスケープの両方で使用できるようにしたい Web ビューです。このコードの前に、すべてのView Controllerですべてを縦向きにロックしました:

- (BOOL)shouldAutorotateToInterfaceOrientation:    (UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

しかし、Xcode 4.5/IOS6 に更新すると、それらすべてが突然反転する可能性があります。そこで、マップ ビューと Web ビューを反転可能にしておくことにしました。しかし、ポートレートでロックしたいメニューがあり、上記のコードでも次のコードでも機能しません。

}

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

何か案は?

よろしくお願いします!

4

1 に答える 1

0

Project -> Targets -> Project Name -> Summary -> Supported Interface Orientations -> Portrait のプロジェクト設定から行うことができます。

または、次を appdelegate に追加することもできます -

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;

}

そして、あなたのviewcontrollerに以下を追加してください -

- (NSUInteger)supportedInterfaceOrientations
{
//    UIInterfaceOrientationMaskLandscape;
//    24
//
//    UIInterfaceOrientationMaskLandscapeLeft;
//    16
//
//    UIInterfaceOrientationMaskLandscapeRight;
//    8
//
//    UIInterfaceOrientationMaskPortrait;
//    2

//    return UIInterfaceOrientationMaskPortrait;
//    or
return UIInterfaceOrientationMaskPortrait;
}

-(BOOL) shouldAutorotate
{
    return YES;
}
于 2012-12-25T04:56:21.307 に答える