views:

208

answers:

0

Hi guys

In my app, after selecting a contact I would like to then directly bring up another view window.

I'm in the method

- (BOOL)peoplePickerNavigationController: (ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person {

and after selecting the person (in the above method, which i feel is the right section) I want to open a new view controller, to work with this info. Is this possible? I am not able to do it.

All the contact calls work correctly.

The code i want to execute to open my 'later' view is :

  if(avController == nil)
   avController = [[AddViewController alloc] initWithNibName:@"AddView" bundle:nil];

  if(addNavigationController == nil)
   addNavigationController = [[UINavigationController alloc] initWithRootViewController:avController];

  [self.navigationController presentModalViewController:addNavigationController animated:YES]; 

This works perfectly when i click a button, or a uialertviewbutton etc.

My code which does not allow me to bring up the above avController code is:

- (BOOL)peoplePickerNavigationController: (ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person {

 NSString *contactFirst;
 NSString *contactLast;

 contactFirst = [(NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty) stringByAppendingString:@" "]; 
 contactLast =  (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty);
 contactName = [contactFirst stringByAppendingString:contactLast];
 contactCompany = (NSString *)ABRecordCopyValue(person, kABPersonOrganizationProperty);

 recordId = [NSNumber numberWithInteger: ABRecordGetRecordID(person)];

 //UIAlertView *baseAlert = [[UIAlertView alloc]  initWithTitle:@"Selected Person" message:contactName delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
 //[baseAlert show];

 NSLog(@"record id is %@",recordId);
 NSLog(@"Person Reference: %d", person);
 NSLog(@"Name: %@", contactName);
 NSLog(@"Company: %@", contactCompany);


// txtCoffeeName.text = contactName;
// NSString *personStr = [NSString stringWithFormat:@"%@", recordId];
// txtPersonID.text = personStr;


// if (contactCompany != nil) txtCompanyName.text = contactCompany;

 // remove the controller
    [self dismissModalViewControllerAnimated:YES];

 if(avController == nil)
  avController = [[AddViewController alloc] initWithNibName:@"AddView" bundle:nil];

 if(addNavigationController == nil)
  addNavigationController = [[UINavigationController alloc] initWithRootViewController:avController];

 [self.navigationController presentModalViewController:addNavigationController animated:YES]; 



// if (![txtCompanyName.text isEqualToString:@""]){
//  [txtPrice becomeFirstResponder];
// } else [txtCompanyName becomeFirstResponder];


 return YES;

can someone see what is incorrect with my peoplePickerNavigationController class? It doesnt bring up the addNavigationController, yet, if i replace it will a UIAlert, the UIAlert works.

Regards, @norskben