如何编写代码从电话簿中选择所选的电话号码地址,从我的iphone应用程序发送消息

时间:2012-04-27 05:39:53

标签: iphone object jailbreak mfmailcomposeviewcontroller mfmessagecomposeview

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

它很精细,但问题出在选择收件人的数量

在我的代码中是在textfiled中输入的值

我想从电话簿联系人处获取该号码。

如何检索这个任何帮助

13 C ontactNUMBER = 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)发件人

{

}

//消息编辑器委托方法

- (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];
}

1 个答案:

答案 0 :(得分:1)

获取iPhone联系人Apple提供ABPeoplePickerViewController