문제

How to rotate from portrait to landscape? What would I have to implement? And what must I do that my views resize to the new width?

도움이 되었습니까?

해결책

The below method "return yes" will make orientation change if it is "return NO" the orientation will not change.

- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) orientation 
{

 return YES;

}

All the best.

다른 팁

To answer the second part of your question, you can add logic to resize or position views by overriding the -willRotateToInterfaceOrientation:duration: method, e.g.:

- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    if (toInterfaceOrientation == UIDeviceOrientationUnknown || toInterfaceOrientation == UIDeviceOrientationFaceUp || toInterfaceOrientation == UIDeviceOrientationFaceDown) {
        // do something here for these orientations
    }
    else {
        // do something else for the remaining orientation types
    }
}

if your view controller is not the top-layer view controller, you must pass the message willRotateToInterfaceOrientation:duration: from the top-layer view controller.. your view controller might not receive the message...

at my top-layer view controller's willRotateToInterfaceOrientation:duration:, i included this line... (frameViewController is my 2nd level view controller)

if (frameViewController)
        [frameViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top