3

我环顾四周,但我还没有找到解决这个奇怪的具体问题的方法。我有一个 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];
}
}
4

0 回答 0