1

Xcode 4.6 と、IOS 5.0 をサポートするアプリがあります。IOS シミュレータ 6 でアプリケーションを実行すると、IOS 5 のときに自動回転が機能します。デバイスでも同じです。

ストーリーボードを使用しました。

注入機能の自動回転中のブール値 - true。

4

2 に答える 2

1

iOS6 では、ビューを回転させるかどうかを決定するための新しい方法が導入されましたが、iOS5 では古い方法を使用する必要があります。iOS6 の方法のみを使用している可能性があります。これが私が使用するものです:

// New iOS6 autorotate interface.
- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
        return UIInterfaceOrientationMaskAllButUpsideDown;
    else
        return UIInterfaceOrientationMaskAll;
}

// Older autorotate interface (for compatibility).
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    else
        return YES;
}
于 2013-04-01T09:23:27.160 に答える
0

iOS5用

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

ただし、上記のメソッドは、これを使用するオーバーライドとしてios6では非推奨です

- (BOOL)shouldAutorotate {
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}
于 2013-04-01T09:25:30.920 に答える