UISplitViewController 方向改变时 Barstyle 也会改变

发布于 2024-09-29 14:09:13 字数 260 浏览 2 评论 0原文

在我的 iPad 应用程序中,我通过以下代码将 barStyle 属性设置为 UIBarStyleBlack:

// in viewDidLoad
self.navigationController.toolbar.barStyle = UIBarStyleBlack;

奇怪的是,当我旋转 iPad 时,barStyle 将有时重置为灰色/灰色。关于为什么会发生这种情况有什么想法吗?

In my iPad app, I have the barStyle property set to UIBarStyleBlack by this code:

// in viewDidLoad
self.navigationController.toolbar.barStyle = UIBarStyleBlack;

Strangely, when I rotate my iPad, the barStyle will sometimes reset to the gray / grey color. Any ideas on why this might be happening?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

往日 2024-10-06 14:09:13

其实

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:YES];
    self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
}

会解决的。

Actually

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:YES];
    self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
}

will fix it.

裸钻 2024-10-06 14:09:13

这似乎与这个问题相同,该问题已被接受在我看来,答案似乎会起作用。

该问题中提供的信息帮助我理解该问题。在旋转时,不同的视图控制器被隐藏和显示,并且可能会释放它们的属性。答案的作者建议使用来自 UISplitViewController 的委托回调来确定何时重新设置栏样式,而不是标准 UIView 回调:

http://developer.apple.com/library/ios/ #documentation/uikit/reference/UISplitViewControllerDelegate_protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40009454

This seems to be the same as this question, which has an accepted answer that seems to me like it would work.

The information provided in that question help me understand the problem. On rotation, different view controllers are being hidden and shown, and potentially, their properties deallocated. The answer's author suggests using the delegate callbacks from UISplitViewController to find out when to re-set your bar style, not the standard UIView callbacks:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UISplitViewControllerDelegate_protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40009454

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文