我正在将一个应用程序移植到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;
}如何在用户不旋转设备的情况下强制触发shouldHideViewController回调?
谢谢,Fabrizio Bartolomucci
发布于 2015-08-11 21:57:17
我按照Apple的文档建议只根据用户的指示打开它,从而最终摆脱了它。现在我只为一个辅助面板恢复了它,用户实际上是手动打开的,然后在iPhone版本上由一个展开的段来管理。
发布于 2012-09-29 00:04:57
比预想的简单:我在调用你的函数后不久就放入了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;
}发布于 2012-09-25 00:42:36
而不是
spv.delegate=nil;
spv.delegate=self;你需要做的是
[spv willRotateToInterfaceOrientation:self.interfaceOrientation duration:0];你会很开心的。
https://stackoverflow.com/questions/12029162
复制相似问题