首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UISplitViewControlller主控制器隐藏

UISplitViewControlller主控制器隐藏
EN

Stack Overflow用户
提问于 2012-08-20 03:04:45
回答 4查看 3.5K关注 0票数 3

我正在将一个应用程序移植到iOS 6上,我发现了一个解决方案,可以在iOS 6上触发拆分视图控制器中主视图控制器的显示和关闭。

这是我用来触发iOS6上的操作的代码片段,如果设备旋转了,它就会起作用:

代码语言:javascript
复制
- (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

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2015-08-11 21:57:17

我按照Apple的文档建议只根据用户的指示打开它,从而最终摆脱了它。现在我只为一个辅助面板恢复了它,用户实际上是手动打开的,然后在iPhone版本上由一个展开的段来管理。

票数 0
EN

Stack Overflow用户

发布于 2012-09-29 00:04:57

比预想的简单:我在调用你的函数后不久就放入了spv.view setNeedsLayout,它完美地完成了这项工作。这是为了方便其他用户而编写的完整代码:

代码语言:javascript
复制
- (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;  
}
票数 5
EN

Stack Overflow用户

发布于 2012-09-25 00:42:36

而不是

代码语言:javascript
复制
spv.delegate=nil;
spv.delegate=self;

你需要做的是

代码语言:javascript
复制
[spv willRotateToInterfaceOrientation:self.interfaceOrientation duration:0];

你会很开心的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12029162

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档