Проблема с отправкой почты с симулятора - PullRequest
1 голос
/ 29 апреля 2011

Я пытаюсь создать небольшие почтовые приложения. Все работает правильно, но письмо не отправляется. Должен ли я сделать что-то для этого. Я учусь сам. так что мне чего-то не хватает. вот мой код ..

-(void)viewDidLoad
{
    UIButton *but01 = [UIButton buttonWithType:UIButtonTypeRoundedRect];                    //Button I
    but01.frame = CGRectMake(240,10, 70, 50);
    [but01 setTitle:@"ADD" forState:UIControlStateNormal];
    [but01 addTarget:self action:@selector(sendMail) 
    forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:but01];


}

- (IBAction)sendMail {
    if ([MFMailComposeViewController canSendMail]) {
        MFMailComposeViewController *mfViewController = [[MFMailComposeViewController alloc] init];
        mfViewController.mailComposeDelegate = self;

        [self presentModalViewController:mfViewController animated:YES];
        [mfViewController release];
    }else {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Status:" message:@"Your phone is not currently configured to send mail." delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil];

        [alert show];
        [alert release];
    }
}


#pragma mark -
#pragma mark MFMailComposeViewControllerDelegate Methods

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Status:" message:@"" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil];

    switch (result) {
        case MFMailComposeResultCancelled:
            alert.message = @"Message Canceled";
            break;
        case MFMailComposeResultSaved:
            alert.message = @"Message Saved";
            break;
        case MFMailComposeResultSent:
            alert.message = @"Message Sent";
            break;
        case MFMailComposeResultFailed:
            alert.message = @"Message Failed";
            break;
        default:
            alert.message = @"Message Not Sent";
        break;  }
    [self dismissModalViewControllerAnimated:YES];

    [alert show];
    [alert release];
}

Для этого я получаю это сообщение в консоли. Что я могу сделать сейчас?

29/04/11 4:03:04 PM SpringBoard[3115]   Reloading application state for 'com.yourcompany.Sendmail' as its modification date has changed    
29/04/11 4:03:04 PM com.apple.launchd.peruser.501[95]   (UIKitApplication:com.yourcompany.Sendmail[0x38e1][3206]) Exited: Killed    
29/04/11 4:03:04 PM SpringBoard[3115]   Reloading and rendering all application icons.    
29/04/11 4:03:04 PM SpringBoard[3115]   Application 'Sendmail' exited abnormally with signal 9: Killed

1 Ответ

2 голосов
/ 29 апреля 2011

MFMailCompose не работает в симуляторе, проверьте его на устройстве

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...