UIActionSheet Cancel button keeps crashing my app

Posted by user337174 on Stack Overflow See other posts from Stack Overflow or by user337174
Published on 2010-05-12T13:30:23Z Indexed on 2010/05/12 13:34 UTC
Read the original article Hit count: 191

Filed under:
|
|

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]];
    }
}

}

© Stack Overflow or respective owner

Related posts about uiactionsheet

Related posts about iphone