Fab*_*cci 3 rotation uisplitviewcontroller ios6
我正在将应用程序移植到iOS 6,我找到了一个解决方案,我已经设法触发断开视图控制器中的主视图控制器的显示,不再适用于iOS 6.
这是我用来触发iOS6上的操作的代码片段,如果设备被旋转:
- (void)hideMaster:(BOOL)hide {
[self clearOverlay];
UISplitViewController* spv = appDelegate.splitViewController;
NSLog(@"hidemaster: I do %@show the master", (hide?@"not ":@""));
self.hiddenMaster= hide;
NSLog(@"delegate=%@", spv.delegate);
[spv.view setNeedsLayout];
spv.delegate=nil;
spv.delegate=self;
}
- (BOOL)splitViewController:(UISplitViewController*)svc shouldHideViewController: (UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation {
NSLog(@"Spv: I do %@show the master", (self.hiddenMaster?@"not ":@""));
return self.hiddenMaster;
}
Run Code Online (Sandbox Code Playgroud)
如何在用户旋转设备时强制触发shouldHideViewController回调?
谢谢,Fabrizio Bartolomucci
比预期更容易:我把[spv.view setNeedsLayout]; 在调用你的功能之后很快就完成了这项工作.这是为了其他用户的利益的完整代码:
- (void)hideMaster:(BOOL)hide {
NSLog(@"hide-unhide master");
UISplitViewController* spv = appDelegate.splitViewController;
spv.delegate=self;
self.hiddenMaster= hide;
[spv willRotateToInterfaceOrientation:self.interfaceOrientation duration:0];
[spv.view setNeedsLayout];
}
- (BOOL)splitViewController:(UISplitViewController*)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation {
NSLog(@"Spv: I do %@ show the master", (self.hiddenMaster?@"not ":@""));
return self.hiddenMaster;
}
Run Code Online (Sandbox Code Playgroud)