开发者

Getting some errors on UIAlertView

I have no idea why t开发者_运维技巧his is happening. It looks correct to me. I wrote another UIAlertView and it looked like it would be fine and as soon as I deleted this one it error-ed the one I wrote. I'm trying to follow this tutorial.

This is in my viewcontroller.m

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{


switch (result) {
        case MessageComposeResultCancelled:
            NSLog(@"Cancelled");
            break;
        case MessageComposeResultFailed:
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Welcome To My App" message:@"This app will ... First you need to ..." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
            [alert show];
            [alert release];

        break;
    case MessageComposeResultSent:

        break;
    default:
        break;
}

[self dismissModalViewControllerAnimated:YES];
}

The errors are showing up on numerous lines of it such as: Missing "[" at start of message send expression. (If I have it put it in it wants to put another and another and another after initWithTitle:)

Next error is: Use of undeclared indentifier 'alert' (says this at the show and release)

Any idea what is going on? Thanks in advance.


Try adding brackets to your case statement that has multiple lines.

- (void)messageComposeViewController:(MFMessageComposeViewController
*)controller didFinishWithResult:(MessageComposeResult)result {


switch (result) {
        case MessageComposeResultCancelled:
            NSLog(@"Cancelled");
            break;
        case MessageComposeResultFailed: {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Welcome To My App" message:@"This app will ... First you need to ..." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
            [alert show];
            [alert release];

        break;
        }
    case MessageComposeResultSent:

        break;
    default:
        break; }

[self dismissModalViewControllerAnimated:YES]; }


why are You set the delegate, if you have not extra buttons in your Alert? I think, You should change delegate:self to delegate:nil.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜