I'm using the pod of SDCAlertView, found here, to implement a series of alert messages with images and other features. The alerts are centered around audio events (ie. headset inserted or removed) and need to be dismissed sometimes without the alert button being clicked.
The issue occurs after I call dismissWithClickedButtonIndex: animated:
. The call itself appears to work jut fine but once that alert is gone the next UIView becomes unresponsive.
One instance of the dismissWithClickedButtonIndex: animated:
call happens in this callback:
- (void) audioRouteChangeListener: (NSNotification *)notification {
// Initiallize dictionary with notification and grab route change reason
NSDictionary *interuptionDict = notification.userInfo;
NSInteger routeChangeReason = [[interuptionDict valueForKey:AVAudioSessionRouteChangeReasonKey] integerValue];
switch (routeChangeReason) {
// Sensor inserted
case AVAudioSessionRouteChangeReasonNewDeviceAvailable:
// Dismiss alert if any and begin collection
if (self.sensorAlert != nil) {
[self.sensorAlert dismissWithClickedButtonIndex:0 animated:YES];
self.sensorAlert = nil;
}
// **** DEBUG ****
NSLog(@"Sensor INSERTED");
break;
default:
NSLog(@"Blowing it in- audioRouteChangeListener with route change reason: %ld", (long)routeChangeReason);
break;
}
}
I added the alertView handler didDismissWithButtonIndex:
and confirmed the dismiss call is making it:
- (void) alertView:(SDCAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
switch (buttonIndex) {
case 0:
// Checking for dismiss
NSLog(@"Made it to standard dismiss\n");
break;
default:
NSLog(@"Uncaught dismiss\n");
break;
}
}
The SDCAlertView instance is part of a class that subclasses NSObject, as opposed to UIViewController, which I guess could be the cause of the issue but then I would assume the clickedButtonAtIndex
call would cause the same effect but it does not.
I set up the SDCAlertView like so:
// Set up alert View for a disconnected sensor
self.sensorAlert = [[SDCAlertView alloc]
initWithTitle:@"No Sensor"
message:@"Please insert the GSF sensor and try again."
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"Try Again", nil];
[alertImageView setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.sensorAlert.contentView addSubview:alertImageView];
[alertImageView sdc_horizontallyCenterInSuperview];
[self.sensorAlert.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[alertImageView]|"
options:0
metrics:nil
views:NSDictionaryOfVariableBindings(alertImageView)]];
Any help in figuring out this problem is greatly appreciated.