【问题标题】:Navigation bar tint color changes after auto dimissal of UIAlertViewUIAlertView 自动关闭后导航栏色调颜色发生变化
【发布时间】:2014-02-11 19:38:10
【问题描述】:

我已经编写了自定义 UIAlertview 以允许在某些情况下自动关闭。现在,在 iOS 7 中,当自动关闭发生时,我的导航栏的色调会发生变化。根据 iOS7 过渡指南:

https://developer.apple.com/library/ios/documentation/userexperience/conceptual/transitionguide/TransitionGuide.pdf

当出现警报或操作表时,iOS 7 会自动调暗其后面视图的色调。为了响应这种颜色变化,在其渲染中使用 tintColor 的自定义视图子类应覆盖 tintColorDidChange 以在适当时刷新渲染。

任何想法是否可以仅在自定义 UIAlertView 中处理。下面是我的自定义 UIAlertView 代码:

#define kStartupFailAlert 203

#import "RunnerUIAlertView.h"

@implementation RunnerUIAlertView

- (id)init {
    self = [super init];

    if (self) {
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(removeAlert) name:kRemoveVisibleAlert object:nil];
    }

    return self;
}


- (void)removeAlert {  
    if (self.tag != kStartupFailAlert) { // If not kRunnerStartupFailAlert - as it will be auto dismissed
        self.delegate = nil;
        NSInteger aCancelButtonIndex = [self cancelButtonIndex];
        [super dismissWithClickedButtonIndex:aCancelButtonIndex animated:NO];
    }
}


- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

@end

【问题讨论】:

    标签: ios objective-c cocoa-touch uiview uialertview


    【解决方案1】:

    通过恢复应用代理窗口上的色调设置来解决这个问题。但是,它具有在打开弹出框或工作表时不会使导航色调变暗的副作用。这似乎是 iOS7 SDK 的问题。

    - (void)removeAlert {
        if (self.tag != kStartupFailAlert) { // If not kRunnerStartupFailAlert - as it will be auto dismissed
            self.delegate = nil;
            NSInteger aCancelButtonIndex = [self cancelButtonIndex];
            [self dismissWithClickedButtonIndex:aCancelButtonIndex animated:NO];
    
            MyAppDelegate *appDeletgate = [Utilities applicationDelegate];
            appDeletgate.window.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-03
      • 1970-01-01
      相关资源
      最近更新 更多