Question

I have an email delegate method that shows a result message. After the result message is displayed, how to set the message disappear forever so that it's not sticking there? Here is the snippet of code.

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{   
    message.hidden = NO;

    switch (result)
    {
        case MFMailComposeResultCancelled:
            message.text = @"Email canceled";

            break;
        case MFMailComposeResultSaved:
            message.text = @"Email saved";

            break;
        case MFMailComposeResultSent:
            message.text = @"Email sent";

            break;
        case MFMailComposeResultFailed:
            message.text = @"Email failed";

            break;
        default:
            message.text = @"Email not sent";

            break;

    }

    [self dismissModalViewControllerAnimated:YES];

}
Was it helpful?

Solution

Sounds like you probably want an NSTimer, something like:

    ...
    [self dismissModalViewControllerAnimated:YES];

    NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:2.0 ///< Change to number of seconds before `message' will be "cleared"
                                                      target:self 
                                                    selector:@selector(clearMessage) 
                                                    userInfo:nil 
                                                     repeats:NO];
}

- (void)clearMessage {
    message.hidden = YES;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top