1

私の iPad アプリには、UIScrollView があります。「iPad 5 シミュレーター」で実行すると、AutorotateToInterfaceOrientation が発生し、すべて問題ないはずですが、「iPad 4.3 シミュレーター」では、このイベントは発生しません。

この問題を解決するにはどうすればよいですか?

別の問題:「iPad 5シミュレーター」でアプリをテストすると、このイベントは起動時に7回発生します

ここに私のコードの一部があります:

#import "AppDelegate.h"

#import "ContentController.h"

@implementation AppDelegate

@synthesize window, contentController;


- (void)applicationDidFinishLaunching:(UIApplication *)application
   {
    NSString *nibTitle = @"iPad";
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    { nibTitle = @"Iphone";
    }
    [[NSBundle mainBundle] loadNibNamed:nibTitle owner:self options:nil];

    [self.window addSubview:self.contentController.view];

    [window makeKeyAndVisible];
    }

@end

contentController.h

@interface ContentController : UIViewController

{
    NSArray *contentList;
}

@property (nonatomic, retain) NSArray *contentList;

@end

PadContentController.h

@interface PadContentController : ContentController <UIScrollViewDelegate>
        {   
        UIScrollView *appScrollView;
        NSMutableArray *viewControllers;
        }

    @property (nonatomic, retain) IBOutlet UIScrollView *AppScrollView;


    @property (nonatomic, retain) NSMutableArray *viewControllers;


    @end

shouldAutorotateToInterfaceOrientation は PadContentController にあります。

   -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
            {
                [super shouldAutorotateToInterfaceOrientation:interfaceOrientation];
                switch (interfaceOrientation)
                {

                    case UIInterfaceOrientationPortraitUpsideDown:
                    case UIInterfaceOrientationPortrait:
                      return NO;

                    default:
                        return YES;
                }
            }

UIScrollView にいくつかのビューを追加しました。shouldAutorotateToInterfaceOrientation もこれらの各ビューに実装されています。「iPad 5 シミュレーター」でアプリを実行すると、PadContentController とすべてのビューで shouldAutorotateToInterfaceOrientation が呼び出されます。しかし、「iPad 4.3 シミュレーター」で実行すると、最初のビューで shouldAutorotateToInterfaceOrientation が呼び出され (起動時のみ)、PadContentController で shouldAutorotateToInterfaceOrientation が呼び出されないため、回転が発生しません。

4

0 に答える 0