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?
+2
A:
Hi
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.
Warrior
2010-06-29 20:08:56
This means it will auto-rotate to all orientations, which is the goal for apps now. If you wanted to restrict the orientations, you can return whether the given orientation (the argument) is equal to one of [these](http://developer.apple.com/iphone/library/documentation/uikit/reference/UIApplication_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006728-CH3-SW5).
paxswill
2010-06-29 20:12:00
A:
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
}
}
Alex Reynolds
2010-06-29 20:20:32
A:
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];
Yit Ming
2010-08-25 03:59:32