Pregunta

I have written my custom UIAlertview to allow auto dismissal in certain cases. Now, with iOS 7 when auto dismissal happens the tint color of my nav bar changes. As per the iOS7 Transition Guide:

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

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.

Any idea if this can be handled from with in the custom UIAlertView only. Below is my code for custom 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
¿Fue útil?

Solución

Got this worked out by restoring the tint settings on app delegate's window. But then it has this side effect of not dimming the navigation tint color when opening a popover or a sheet. It seems be an issue with 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;
    }
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top