UIViewController 横向模式按钮不起作用

Red*_*eye 3 iphone objective-c ios

我正在尝试让应用程序在横向模式下工作,我几乎已经完成了,但由于某种原因,我视图上的按钮不起作用(即它们没有按下)。我正在使用一个根视图控制器,它按如下方式加载初始视图控制器:

        - (void)viewDidLoad 
{

        [super viewDidLoad];

        StartViewController *viewController = [[StartViewController alloc] initWithNibName:@"StartView" bundle:nil];
        self.startViewController = viewController;
        startViewController.delegate = self;
        [viewController release];

        [self.view addSubview:startViewController.view];
    }
Run Code Online (Sandbox Code Playgroud)

我还在我的 Info.plist 文件中设置了 Initial Interface Orientation 值,并在我的根视图控制器中覆盖了以下内容:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    // Return YES for supported orientations
    return((interfaceOrientation == UIInterfaceOrientationLandscapeRight) ||
           (interfaceOrientation == UIInterfaceOrientationLandscapeLeft));
    //return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
Run Code Online (Sandbox Code Playgroud)

视图可以正常加载并以横向模式填充屏幕,但由于某种原因,我无法按下视图上的任何按钮。

我确信这与我使用根视图控制器有关的事情很简单,因为我之前已经设法使用只有一个视图控制器的应用程序使其正常工作。

有人可以帮我吗?

Yur*_*ras 5

我认为问题出在xib的某个地方。例如,按钮放置在UIView不正确的调整大小蒙版上。所以在横向模式下,按钮出现在视图之外,触摸无法到达按钮。您可以clipSubviews在所有父视图中检查它的设置——如果我是对的,您将不会再看到该按钮。