开发者

UIViewController landscape mode buttons not working

I'm trying to get an app working in landscape mode which I've very nearly done, but for some reason the buttons on my view aren't working (ie. they don't press). I'm using a root view controller which loads the initial view controller as follows :

        - (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开发者_运维知识库];
    }

I've also set the Initial Interface Orientation value in my Info.plist file and overridden the following in my root view controller :

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

The view loads fine and fills the screen in landscape mode as it should, but for some reason I just can't press any of the buttons on the view.

I'm sure it's something simple related to me using a root view controller because I've managed to get this to work fine before with an app with just a single view controller.

Can anybody help me out here?


I think the problem is somewhere in xib. E.g. the button is placed on UIView with incorrect resize masks. So that in landscape mode the button appears outside the view, and touches can't reach the button. You can check it setting clipSubviews in all the parent view -- if I'm right, you will not see the button any more.


I had a simular problem. In my case I was subclassing a UITableViewCell and I has overwritten the layoutSubviews method. In there I was doing translations. But I forgot to put the [super layoutSubviews]; before my implementation. After I put it htere, the button were working again in landscape mode. It was strange that in portrait it worked and in landscape not.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜