【问题标题】:How to specify/add receiver's number in MFMessageComposerViewController?如何在 MFMessageComposeViewController 中指定/添加接收者的号码?
【发布时间】:2013-07-02 15:26:13
【问题描述】:

我的代码中有以下清单。

- (IBAction)sendText:(id)sender {
if ([MFMessageComposeViewController canSendText]) {
    MFMessageComposeViewController *textSheet=[[MFMessageComposeViewController alloc]init];
    textSheet.messageComposeDelegate=self;
    [textSheet setBody:@"Demonic Possessions"];
    [self presentViewController:textSheet animated:YES completion:nil];

}  else  {
    UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Error!" message:@"Not Supported With Device" delegate:nil cancelButtonTitle:@"OK!" otherButtonTitles:nil, nil];
    [alert show];
}

}

但是代码中没有指定接收者的号码。

是否可以使用 MFMessageComposerViewController 向特定的联系人号码发送消息?

如果没有,那我该怎么做? 一个代码会很有帮助...

【问题讨论】:

    标签: objective-c ios6 messageui mfmessagecomposeview


    【解决方案1】:

    使用recipients 属性。将其设置为 NSArray 的电话号码作为 NSStrings。

    textSheet.recipients = @[@"1234", @"3234"];
    

    【讨论】:

    • 它不能与模拟器一起工作,对吧?我必须使用实际设备?
    • 在实例化类之前,始终检查 canSendText 属性是否为真。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多