0

私はviewcontrollerの1つでUITabbarcontrollerを使用しています.1つのタブバーではメールコントローラのみが必要です.そうしているときに,それは無限ループに入ります.どうすればそれを克服できますか.関連するコード

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
    mailViewController.mailComposeDelegate = self;

    if ([MFMailComposeViewController canSendMail]) {

        [mailViewController setToRecipients:[NSArray arrayWithObject:@"k.sourish.k@gmail.com"]];
        [mailViewController setSubject:@"Subject Goes Here."];
        [mailViewController setMessageBody:@"Your message goes here." isHTML:NO];

        [self presentModalViewController:mailViewController animated:YES];
    }
    else {

        NSLog(@"Device is unable to send email in its current state.");
        UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Error" message:@" Please Configure Your Mail Account" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [alert show];
        [alert release];

    }
    [mailViewController release];
}

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {    NSString *message = @"";
    // Notifies users about errors associated with the interface
    switch (result) {
        case MFMailComposeResultCancelled:
            message = @"Mail: canceled";
            break;
        case MFMailComposeResultSaved:
            message = @"Mail: saved";
            break;
        case MFMailComposeResultSent:
            message = @"Mail: sent";
            break;
        case MFMailComposeResultFailed:
            message = @"Mail: failed";
            break;
        default:
            message = @"Mail: not sent";
            break;
    }
    UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Alert" message:message delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [alert show];
    [alert release];

    [controller dismissModalViewControllerAnimated:YES];
}
4

1 に答える 1