I have had many successes programming the iPhone in Landscape mode, but I have been unable to get the Apple PageControl demo to run in Landscape mode and render the content correctly. The demo uses the AppDelegate class as an implicit ViewController which ma开发者_如何转开发nages a UIScrollView, and the AppDelegate creates a set of UIViewControllers for the ScrollView's contents, 1 controller per page. In addition there is a UIPageControl object that the AppDelegate manages.
I can get the demo code to run in Landscape mode, but the contents always render as if they were in portrait mode, so while the simulator displays he device in Landscape mode, the pageControl is always on the side of the screen.
If anyone has gotten the contents to rotate correctly, I would really appreciate an explanation of how you got it to work.
I think it doesn't work because the scrollview is attached to window, and the window doesn't have a autorotate method like a view, it seems. If you put the scrollview in a view and then that view in the window, and the views controller has the shouldAutorotateToInterfaceOrientation method defined, it works. However, there is still a bit more work to do as the bounds of the pages are now wrong and need to be reset.
精彩评论