开发者

How to fullscreen DetailView of UISplitViewController in Landscape

开发者 https://www.devze.com 2023-03-31 08:28 出处:网络
I have a UISplitViewController with a common detailView (right side). I add a button to detailView in landscape orientation, when the button is clicked, the masterView(left side) will be hide and det

I have a UISplitViewController with a common detailView (right side).

I add a button to detailView in landscape orientation, when the button is clicked, the masterView(left side) will be hide and detailView will become fullscreen. just like the behavior of the Dropbox app for iPad

Now, I can hide the masterView but cannot change detailView to fullscreen by just setting detailviewController.view's frame.

width of splitview's left side = 321, and the detailviewController.view.frame is {{321,0}, {703, 748}} before changed.

If I change the detailview.frame by following code, there is no change happened.

self.frame = CGRectMake(0, 0, 1024, 748);

And It will change posit开发者_StackOverflow中文版ion if I use following code, but that's not fullscreen.

self.frame = CGRectMake(0, 0, 703, 748);

I found if I change the frame with a larger size (ex. 704) than its origin width, the position of the frame will not change.

How to make a detailview to become whole screen width under landscape orientation? Any suggestion will be very appreciated.


I see another possibility to use + transitionFromView:toView:duration:options:completion: method of UIView to exchange UISplitViewCintroller's view for other fullscreen UIView instance in UIWindow view


I have found a solution in the below link to create a custom splitview controller, you can tweak this to get the desired effect. I dont think it is possible to change the frame size of master and detail view of the normal UISplitViewController (I tried in iOS5, it didnt work).

Custom SplitView

-anoop


This can be done with the method viewWillTransitionToSize,this method will be called whenever our device orientation changes and in that the following will help you achieve what you want.

-(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator{
    self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModePrimaryHidden;
}

The preferredDisplayMode can be used to make the master View hide or show or overlay over the Detail View controller.

0

精彩评论

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