gpt4 book ai didi

rotation - UISplitViewController主 Controller 隐藏

转载 作者:行者123 更新时间:2023-12-02 21:32:26 24 4
gpt4 key购买 nike

我正在将一个应用程序移植到 iOS 6,并且发现了一个用于触发和关闭分割 View Controller 中主视图 Controller 显示的解决方案,该解决方案不再适用于 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 回调?

谢谢,法布里齐奥·巴尔托洛穆奇

最佳答案

比预期容易:我把 [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;
}

关于rotation - UISplitViewController主 Controller 隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12029162/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com