12

iOS6とiOS5の両方をサポートするために、新しいiOS 6自動ローテーションメソッドを追加する意味がないことを誰かが確認できますか?Appleのドキュメントでは、iOS 5メソッドも実装している場合、これらのメソッドは完全に無視されると示唆されていますか?

特に、私はメソッドについて話します- (NSUInteger)supportedInterfaceOrientations-- (BOOL) shouldAutorotateあなたがまた実装する場合、これらは無視され、コンパイラによって合成されます- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

4

6 に答える 6

8

アプリを新しいSDKにパッケージ化する場合は、自動ローテーション用の新しいコールバックを追加する必要があります。ただし、これらのコールバックは、そのようなアプリがiOS6デバイスで実行されている場合にのみ受信されます。以前のiOSバージョンで実行されているデバイスの場合、以前のコールバックが受信されます。新しいコールバックを実装しない場合、デフォルトの動作では、アプリはiPadのすべての方向で実行され、iPhoneのUpsideDown方向を除くすべてで実行されます。

于 2012-09-17T09:38:11.970 に答える
8

iOS5ローテーションの場合。希望の向きを確認し、YESを返します

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{  
    if ((interfaceOrientation==UIInterfaceOrientationPortrait)||(interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown)) {
        return YES;
    }
    else return NO;
}

iOS6.0自動回転のサポート

- (BOOL)shouldAutorotate
{
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationIsPortrait(UIInterfaceOrientationMaskPortrait|| UIInterfaceOrientationMaskPortraitUpsideDown);

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationIsPortrait(UIInterfaceOrientationPortrait|| UIInterfaceOrientationPortraitUpsideDown);

}
于 2012-12-10T12:25:10.357 に答える
2

最もエレガントな解決策は次のとおりです。

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return ((1 << toInterfaceOrientation) & self.supportedInterfaceOrientations) != 0;
}

私は何かが恋しいですか?

于 2012-12-03T13:44:08.893 に答える
1
 - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationMaskAll;
}

-(void)viewWillLayoutSubviews
{
if([self interfaceOrientation] == UIInterfaceOrientationPortrait||[self interfaceOrientation] ==UIInterfaceOrientationPortraitUpsideDown)
    {
       if (screenBounds.size.height == 568)
        {
          //set the frames for 4"(IOS6) screen here
         }
        else

        {
         ////set the frames for 3.5"(IOS5/IOS6) screen here
        }

}
        else if ([self interfaceOrientation] == UIInterfaceOrientationLandscapeLeft||[self interfaceOrientation] == UIInterfaceOrientationLandscapeRight)
        {
         if (screenBounds.size.height == 568)
        {
          //set the frames for 4"(IOS6) screen here
         }
        else

        {
         ////set the frames for 3.5"(IOS5/IOS6) screen here
        }


    }
//it is for IOS5
 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
     return YES;
    }

-(void)viewWillLayoutSubviewsこのメソッドはios5/ios6を呼び出します。このコードは、iOS6 / ios5/ios6と3.5"画面/4"画面の両方に役立ちます。

于 2012-11-22T06:44:32.323 に答える
0

2つのうちどちらを使用するかを示すフラグをどこかに設定する必要があります(Info.plistを信じています)。新しいものを使用する場合、iOS 5用にビルドすることはできません(または、少なくともiOS 5では動作しません)。古いメソッドを使用する場合、新しいメソッドは呼び出されません。そうですね、ほとんどの場合、使用するメソッドを選択する必要があります。iOS5をサポートする場合は、新しいメソッドを使用できません。

于 2012-09-15T06:13:48.510 に答える
0

ios5とios6の両方で自動ローテーションをサポートするには、ios6の場合にコールバックを提供する必要があります。

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(orientationChanged:) 
    name:UIDeviceOrientationDidChangeNotification object:nil];

電話する必要があります

- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;

} 

-(BOOL)shouldAutoRotate{
    return YES;
  }

iOS5の場合

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return ((toInterfaceOrientation == UIInterfaceOrientationPortrait) || (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown));
}
于 2013-08-22T07:24:48.647 に答える