MacUser
MacUser

Reputation: 491

UIInterfaceOrientation Xcode

I would like my app to support PortraitUpSideDown orientation. I have changed the info.p list to reflect this and tried to implement the change on one view as a test

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
    return YES;
    return (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
    return YES;

}

But the view does not respond. Do I need to implement this on all views before the app responds? Is there a Xib setting I need to change?

Upvotes: 0

Views: 3794

Answers (1)

sch
sch

Reputation: 27506

If you would like to support both landscape orientations, try the following:

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

Or:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}

Or somethings that looks like what you were trying to write:

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

Upvotes: 5

Related Questions