开发者

Showing a new UIView when rotates

I was following an example in the Beginning iPhone 4 book for creating a new view when the view rotates. I have two views for this ViewController. In

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

I add the PortraitView (typically our app starts in Landscape) as a subview

[self.view addSubview:PortraitView];

and basically hide all elements that are for landscape, and unhide all elements for Portrait. (It seems like I need to do this since my background is clearColor and the elements from the Landscape view show through.

So now, I want to select an item in Portrait view (it's a UITableView), and go to another detailView in Portrait mode. If the user rotates back to Landscape, then I'd like to go back to where they were in the original Landscape position. When I show this new view when an item is selected from the UITableView, should I push a new ViewController and show its view, or should I do another show/hide addSubview? It seems like I should push a new ViewController, but then when this ViewController rotates back to Landscape, how does it know to back to the original Landscape view since it's a differe开发者_如何学Pythonnt ViewController. I'm trying to figure out the best way to design it now, for the least amount of decoupling later. Thanks.


You can consider presentModalViewController:animated: for the portrait mode.

Look at the sample code for AlternateViews at

http://developer.apple.com/library/ios/#samplecode/AlternateViews/Introduction/Intro.html#//apple_ref/doc/uid/DTS40008755

It presents a modal view controller for landscape mode.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜