title: Presenting MFMessageComposeViewController as soon as the user selects a contact from ABPeoplePickerNavigationController
body: <p>Im working on an app which allows the user to select a contact from phone's address book and displays that contact in the UITableView. Im using following code to pick up the contact;</p>
  
  <pre><code>-(IBAction)pickPhoneContacts:(id)sender //opens phone's address book
  {
     ABPeoplePickerNavigationController *picker =
  
     [[ABPeoplePickerNavigationController alloc] init];
  
     picker.peoplePickerDelegate = self;
  
     [self presentViewController:picker animated:YES completion:nil];
  </code></pre>
  
  <p>}</p>
  
  <pre><code>  //called when user presses the cancel button in the Address book view controller
    - (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController*)peoplePicker
  
   {
      [self dismissViewControllerAnimated:YES completion:nil];
   }
  
  
     //called when user pics up a contact from the phone's address book
  
     - (BOOL)peoplePickerNavigationController:
  
    (ABPeoplePickerNavigationController *)peoplePicker
  
    shouldContinueAfterSelectingPerson:(ABRecordRef)person {
  
  
    [self displayPerson:person]; //calls displayPerson:(ABRecordRef)person to show contact's information in the app
  
    [self dismissViewControllerAnimated:YES completion:NULL];
  
     return NO;
  }
  
  
  //called when the user selects the property of the contact. This method will not be called in the  app but included to complete the implementation of the protocol
  
  
  - (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)
  
  peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person
  
   property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
   {
     return NO;
   }
  
     //Displays the contact name and the contact's primary number in the app's text fields (add contact view controller)
   - (void)displayPerson:(ABRecordRef)person
   {
      NSString* name = (__bridge_transferNSString*)ABRecordCopyValue(person,kABPersonFirstNameProperty); //Extracts the contact's first name from address book &amp; assigns it to a string value
  
  
    self.contactNameTextFiled.text = name;
  
    NSString* phone = nil;
  
    //Extracts the first phone number among multiple contact numbers from address book &amp; assigns it to a string value
  ABMultiValueRef phoneNumbers = ABRecordCopyValue(person,kABPersonPhoneProperty);
  
  if (ABMultiValueGetCount(phoneNumbers) &gt; 0)
  {
      phone = (__bridge_transfer NSString*)
  
      ABMultiValueCopyValueAtIndex(phoneNumbers, 0);
  
  }
  else
  {
      phone = @"[None]";
  }
  
  self.primaryNumberTextField.text = phone;
  
  CFRelease(phoneNumbers);
  
  }
  </code></pre>
  
  <p>Now the task is, as soon as the user pics up a contact from the address book, the ABPeoplePickerNavigator should dismiss and immediately MFMessageComposeViewController should present with a default message and the picked contact number. So that the user of the app should send a message to the picked contact number. I have used following code for message compose view controller;</p>
  
  <pre><code>-(void)sendSMS
  {
     MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
     if([MFMessageComposeViewController canSendText])
     {
        controller.body = @"Test Message";
        controller.recipients = [NSArray arrayWithObjects:@"111222333", nil];
        controller.messageComposeDelegate = self;
         [self presentViewController:controller animated:YES completion:nil];
  
     }
  
  }
  </code></pre>
  
  <p>Now please help me where should I call this method so that the MFMessageComposeViewController should present as soon as the ABPeoplePickerNavigationController dismiss.</p>