Mfmessagecomposeviewcontroller在展示后立即解散

时间:2014-06-30 14:45:40

标签: objective-c xcode ios7 sms mfmessagecomposeview

我到处都看了看,但我还没有找到解决这个奇怪的具体问题的方法。我有一个UIToolbar,其中包含一个调用显示MFMessageComposeViewController的方法的按钮。当它被调用时,如果联系人列表中的人还没有发送消息,那么一切都很顺利。但是,如果已经向该人发送了消息,则视图控制器一打开就会解除,即使用户没有机会按下取消按钮,也会触发MessageComposeResultCancelled。关于为什么会发生这种情况的任何想法?

为了更好的衡量,这是我的消息发送方法:

 -(void) showEmailComposer {
if ([MFMessageComposeViewController canSendText]) {

    MFMessageComposeViewController *messageVC = [[MFMessageComposeViewController alloc] init];
    //[messageVC setMessageComposeDelegate:self];

    messageVC.messageComposeDelegate = self;

    NSArray *toRecipients = [NSArray arrayWithObject:@"NUMBER"];
    [messageVC setRecipients:toRecipients];

    NSString *smsString = [NSString stringWithFormat:@"Here's a link to my current location: http://maps.apple.com/?ll=%f,%f", _lat, _lon];
    messageVC.body = smsString;

    messageVC.messageComposeDelegate = self;
    [self presentViewController:messageVC animated:YES completion:nil];
} else {
    UIAlertView *alerty = [[UIAlertView alloc]
                           initWithTitle: @"Unable to send Message"
                           message: @"Sorry, but your device is incapable of sending messages right now."
                           delegate: nil
                           cancelButtonTitle:@"OK"
                           otherButtonTitles:nil];
    [alerty show];
}
}

0 个答案:

没有答案