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

内容控制器.h

@interface 内容控制器: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