gpt4 book ai didi

iphone - 如何在 iOS 7 中以编程方式正确关闭 UIAlertView?

转载 作者:技术小花猫 更新时间:2023-10-29 10:22:43 25 4
gpt4 key购买 nike

当我的应用程序进入后台时,我的模态呈现的 View Controller 会像这样解除警报 View ...

// called when view controller receives a UIApplicationDidEnterBackgroundNotification
- (void)applicationDidEnterBackground:(NSNotification *)notification
{
if (self.alertView) {
[self.alertView dismissWithClickedButtonIndex:0 animated:NO];
self.alertView = nil;
}
}

当我的应用程序在没有终止的情况下返回前台时,警报 View 消失了。但是,导航栏中的栏按钮项(来自 UINavigationController)仍然变暗,就好像警报 View 仍然显示一样。

此外,关闭模态视图 Controller (通过点击变暗的条形按钮项)显示呈现 View Controller 的条形按钮项也变暗。条形按钮项目是可用的,但它们保持灰色。

那么如何取消条形按钮项目的暗淡显示呢?或者,如何在 iOS 7 中以编程方式正确关闭警报 View 以响应应用程序进入后台?

iOS 7 UI 转换指南声明如下:

When an alert or action sheet appears, iOS 7 automatically dims the tint color of the views behind it. To respond to this color change, a custom view subclass that uses tintColor in its rendering should override tintColorDidChange to refresh the rendering when appropriate.

我的导航栏和栏按钮项不是自定义 View ;我没有将它们分类。我在 Storyboard 中创建了具有默认属性的导航栏(与栏按钮项相同)。所以我没有地方可以覆盖 tintColorDidChange。

我的所有 View 都为其 tintColor 属性使用默认值。

我尝试将色调颜色重新设置为默认值但没有成功:

if (self.alertView) {
[self.alertView dismissWithClickedButtonIndex:0 animated:NO];
self.view.tintColor = nil;
self.view.window.tintColor = nil;
self.alertView = nil;
}

我也曾尝试在 View Controller 的 viewDidAppear: 中重新设置色调颜色,但没有成功。

我还尝试将主视图的 tintAdjustmentMode 设置为“正常”但没有成功:

if (self.alertView) {
[self.alertView dismissWithClickedButtonIndex:0 animated:NO];
self.alertView = nil;

self.view.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;
}

顺便说一下,如果应用程序在后台终止,应用程序会重新启动,并且条形按钮项目具有正确的色调(即未变暗)。

最佳答案

我很确定这是 Apple 端的错误。我已经在 https://bugreport.apple.com 提交了错误报告,请提交重复的错误报告以引起 Apple 的注意,如 that is how Apple assigns priority to bugs .

关于iphone - 如何在 iOS 7 中以编程方式正确关闭 UIAlertView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19284438/

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