Iphone: UIAlertView works in simulator but makes the app freeze on iphone
-
20-09-2019 - |
Question
I`m working on a project where an alert should pop up after returning from a controller with an empty value. It does pop up in the simulator, but on the iphone the app freeze and exit when returning from the controller. Any ideas?
Here is my code:
- (void)manualBarcodeViewControllerDidFinish:(ManualBarcodeViewController *)controller
{
......
......
else if([barcode isEqualToString:@""])
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"error" message:@"message" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"otherbutton"];
[alert show];
[alert release];
}
}
Solution
Your otherButtonTitles
argument needs to be nil-terminated.
In general, methods that take a variable number of arguments, need to have nil at the end. For example:
[NSArray arrayWithObjects:objA, objB, nil];
and in your case:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"error" message:@"message" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"otherbutton", nil];
OTHER TIPS
you should look at this question maybe it will help:
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow