3

[This was posted on the Apple Developer Forums but has not been answered, so I'll try here.]

My application uses a UISplitViewController for iPad master/detail views and runs on iOS 6. The split view controller is the root view controller for its window. The detail view consists primarily of a UIWebView embedded in a UINavigationController. The only other elements in the detail view are the toolbar and navigation bar offered by the navigation controller. When the web view is displaying a page with an embedded YouTube video, the user can make the video full screen. This is all done by the UIWebView---I am not responsible for creating a full-screen video player. In case it matters, once the video player is placed in a full-screen view, the keyWindow of the UIApplication shared instance is not the main application window during video playback, but is instead an instance of MPFullScreenTransitionViewController.

If the user rotates the device during this full-screen playback, and then ends playback, the UISplitViewController does not properly place its children. The methods

splitViewController:willHideViewController:withBarButtonItem:forPopoverController:

and

splitViewController:willShowViewController:invalidatingBarButtonItem:

of the delegate (in this case, the detail view controller) are never called.

If the device was rotated to a landscape orientation while playing full-screen video, dismissing the movie player results in the presentation of a detail view controller that retains its former bar button item to draw the master view controller in a popover (although tapping the button produces no action). Where the master view controller should be drawn, only a black region exists. Swiping right in the detail view controller will slide out the master view controller that covers the black region, but this still exists as a popover rather than a persistent view.

If the device was rotated to a portrait orientation while playing full-screen video, dismissing the movie player results in the presentation of a detail view controller that lacks a bar button item to draw the master view controller in a popover. The detail view controller has the correct width, and the master view controller is not visible, so the appearance of the detail view is almost as expected except for the missing bar button item.

In both cases, manually rotating the device after the incorrect view appears will restore proper application functionality. However, relying on the user to rotate (or double-rotate) the device to fix drawing problems is clearly unacceptable.

Is there some way to ensure that the split view controller becomes aware of device rotations when all of its children have disappeared behind a modal movie player?

4

1 回答 1

2

答案是用户 SamuraiZack 在 Apple Developer 论坛上提出的。在 UISplitViewController 的委托中,在 viewWillAppear 中强制重新布局拆分视图控制器:

[self.splitViewController.view setNeedsLayout];
[self.splitViewController.view layoutIfNeeded];

可以在Apple Developer 论坛上查看原始回复。

于 2013-07-29T17:43:08.493 回答