How to open the Edit contact window in iphone app?

Deadly 提交于 2019-12-25 09:01:24

问题


I am adding contact info from my iPhone application on Addcontact click. I just want to open edit contact window on same Addcontact click so user can edit or delete the contact which just now have added. I have done smthing like below..

- (IBAction)AddContact
 {   
ABAddressBookRef addressBook = ABAddressBookCreate();
ABRecordRef Showroom = ABPersonCreate();

//adding contact name as showroom name

ABRecordSetValue(Showroom, kABPersonFirstNameProperty, ShowroomName.text , nil);
   ABAddressBookAddRecord(addressBook, Showroom, nil);
ABAddressBookSave(addressBook, nil);
// Fetch the address book 
//ABAddressBookRef addressBook = ABAddressBookCreate();
// Search for the person named "Appleseed" in the address book

    //ABRecordRef Showroom = (ABRecordRef)[Showroom objectAtIndex:0];
    ABPersonViewController *picker = [[[ABPersonViewController alloc] init] autorelease];
    picker.personViewDelegate = self;
    picker.displayedPerson = Showroom;
    // Allow users to edit the person’s information
    picker.allowsEditing = YES;
[self.navigationController pushViewController:picker animated:YES];
}

this is my Map application. On launching I get showroom results with there contacts. This I can add in to the iPHone contact with edit contact window opening. But when I open other controller to pass user selected string address in to Map controller to search showroom location. The same above code is not working. I mean it only add the contacts but I didnt get the edit contact window.

Edit: May be this problem is regarding navigation controller bar so check the below code also

- (void)viewWillAppear:(BOOL)animated 
   {
  [self.navigationController setNavigationBarHidden:YES animated:animated]; 
   } 
   - (void)viewDidLoad {

[self.navigationController setNavigationBarHidden:NO ];
self.navigationController.navigationBar.tintColor = [UIColor  colorWithRed:25.0/255.0f green:25.0/255.0f blue:25.0/255.0f alpha:1.0f];
   }
- (void)viewWillDisappear:(BOOL)animated
{ 
[self.navigationController setNavigationBarHidden:NO animated:animated];
 }

回答1:


I hope this code is works for you i implements that code and in my application works fine thank you

contecviewcontroller.h
@interface DetailsViewController : UIViewController
DocumentNavController *coffeeObj;
editViewController *evController;
int currentindex;
}

@property (nonatomic, retain) DocumentNavController *coffeeObj;
@property (readwrite, assign) int currentindex;    
@end

contecviewcontroller.m

- (void)viewDidLoad {
  [super viewDidLoad];
//self.navigationController.toolbar.tintColor = [UIColor darkGrayColor];
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]
                                           initWithBarButtonSystemItem:UIBarButtonSystemItemEdit 
                                           target:self action:@selector(goToEdit)]autorelease];
}


-(void)goToEdit{

if(evController == nil)
    evController = [[editViewController alloc]initWithNibName:@"editViewController" bundle:nil];
evernoteAppDelegate *appdelegete = (evernoteAppDelegate *)[[UIApplication sharedApplication]delegate];
coffeeObj = [appdelegete.noteArray objectAtIndex:currentindex];

evController.Editcurrentindex = currentindex;
evController.docedObj = coffeeObj;
[self.navigationController pushViewController:evController animated:YES];
}


来源:https://stackoverflow.com/questions/8575655/how-to-open-the-edit-contact-window-in-iphone-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!