UIScrollView landscape problems
I'm playing around with the page control sample code.
I changed the code to start the app in landscape, the app opened in the simulator but the app was still in portrait mode in a horizontal simulator.
I then put the following code into the PhoneContentController.m file and the MyViewController.m file and changed the MyView.xib view to landscape.
- (BOOL)shouldAutorotateToInterfaceOrientationUIIn terfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape(interfaceOrienta tion);
}
Now what happens is the app starts in landscape mode with the first image displaying correctly. The problem now is the other images are showing o开发者_StackOverflown their sides and the scrollview is scrolling vertically instead of horizontally.
How can I get this to scroll horizontally in landscape mode with all the images also in landscape mode?
The ContentController and PhoneContentController classes are not subclasses of UIViewController. Therefore adding shouldAutorotateToInterfaceOrientation to these classes has no effect.
The rotation event is sent only to the first UIViewController that is added to the window (actually its view is added). In your case, shouldAutorotateToInterfaceOrientation is only called for the first MyViewController which is a subclass of UIViewController. Therefore only the first image is rotated.
To make it work properly you need to find a way to change ContentController such that it extends UIViewController.
精彩评论