Uialertview Is Crashing App on iOS 7

UIAlertView crashes in iOS7

As per crash log it says to me "[UIViewController _loadViewFromNibNamed:bundle:]" unable to load nib file.

But, in my project I had created a category for UIViewController class and overridden the -(id)init method. Upto ios6, while showing an alert this category method is not at all executing, but from ios7 onwards overridden init() method of UIViewController.

So, I fixed this issue by adding the another validation in UIViewController category's init() method for checking the class method is UIAlertView or not, if it is UIAlertView then simply calling [super init]; instead of doing my other stuff relating to view controllers.

Sample code:

    - (id)init
{
NSString *viewControllerName = [NSString stringWithFormat:@"%@",[self class]];
if([viewControllerName isEqualToString:@"UIAlertView"])
{
self = [super init];
}
else
{
// my stuff
}
return self;
}

UIAlertView in viewWillDisappear crashing app on iOS 7

Just for sake of completeness and if anyone else has the same issue, I fixed this by using @darren102 suggestion. Previously I was setting the view controller as a delegate for the UIAlertView, changed this to nil fixed the problem.

UIAlertView makes the program crash

Yes, I've found the solution and I share that with you guys.
I tried to override the dismissWithClickedButtonIndex function, and sent unique buttonIndexes
like 9999 for each of my alerts.
That is,

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
[self viewWillDisappear:YES];
if(buttonIndex == 9999) {
noTicketAlert = [[UIAlertView alloc] initWithTitle:@"Aradığınız kriterlere uygun bilet bulunamadı!" message:nil delegate:self cancelButtonTitle:@"Tamam" otherButtonTitles: nil];
[noTicketAlert show];
}
}

and if I want to display the noticketAlert, I call this method like :

[alert dismissWithClickedButtonIndex:9999 animated:YES];

App crashes due to UIAlerview in ios 7 ,but working fine in ios 6

TSAlertView is updated now to work in IOS 7. They Added a customSubview property . So Please update the latest code from here:

TSAlertView



Related Topics



Leave a reply



Submit