UIActionSheet Cancel button keeps crashing my app
- by user337174
I am really puzzeled by this one. I have set up two UIActionSheets in my application. They work perfectly fine until you use the cancel button in the UIActionSheets.
When i navigate away from the page the UIAactionSheet returns too it crashes my app.
Does anyone have any ideas as too why?
-(IBAction) phoneButtonClicked:(id)sender
{
// open a dialog with just an OK button
phoneActionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:self cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:[NSString stringWithFormat:@"Phone: %@",phone],nil];
phoneActionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[phoneActionSheet showInView:self.view]; // show from our table view (pops up in the middle of the table)
[phoneActionSheet release];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (actionSheet == phoneActionSheet) {
if(buttonIndex == 0){
NSString *callPhone = [NSString stringWithFormat:@"tel:%@",phone];
NSLog(@"Calling: %@", callPhone);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]];
}
}
}