0

我已经实现了这样的发送短信代码......

很好,但问题在于选择收件人的号码

在我的代码中是在文本文件中输入的值,

我不想从电话簿联系人中获取号码。

请如何检索此任何帮助

ContactNUMBER = NumbertxtField.text

//发送短信按钮的方法

-(IBAction)sendSMS:(id)sender
{
     MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];
    if([MFMessageComposeViewController canSendText])
    {


           controller.recipients = [NSArray arrayWithObjects: ContactNUMBER, nil];



           controller.body = messageBody.text;
           controller.messageComposeDelegate = self;
           [self presentModalViewController:controller animated:YES];
        }
}

![在此处输入图像描述][1]

//点击DiscloserButton从电话簿中选择联系人的方法

-(IBAction)phoneBook_DiscloserButton : (id)sender

{

}

//消息编写器委托方法

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
    switch (result) {
        case MessageComposeResultCancelled:
            NSLog(@"Cancelled");
            break;

        case MessageComposeResultFailed:
        {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sharing our app" message:@"Unknown Error"
                                                           delegate:self cancelButtonTitle:@"Ok"otherButtonTitles: nil];
            [alert show];
            [alert release];
        }
            break;

        case MessageComposeResultSent:

            break;
        default:
            break;
    }

    [self dismissModalViewControllerAnimated:YES];
}
4

1 回答 1

1

为了获取 iPhone 联系人,Apple 提供 ABPeoplePickerViewController

于 2012-04-27T06:34:24.093 回答