2

I create new CNContactViewController for add new contacts on phone directory but when I navigate to controller CNContactViewController navigation back button is hidden. Following my code.

    CNContactStore *store = [[CNContactStore alloc] init];
    CNMutableContact *contact = [[CNMutableContact alloc] init];
    contact.familyName = @"name_1";
    contact.givenName = @"xyz";

    CNLabeledValue *homePhone = [CNLabeledValue 
    labeledValueWithLabel:CNLabelHome value:[CNPhoneNumber 
    phoneNumberWithStringValue:@"0123456789"]];
    contact.phoneNumbers = @[homePhone];

    CNContactViewController *contactVC = [CNContactViewController 
    viewControllerForNewContact:contact];
    contactVC.contactStore = store;
    contactVC.delegate = (id)self;
    [self.navigationController pushViewController:contactVC animated:TRUE];

Please suggest me best solution for showing back & Done button using Objective-C or Swift-3.

1 Answers1

0

I suggest you use a UINavigationViewController to wrap your viewControllers in.

This way you can use segues (lookup: push and popViewControllerAnimated) to navigate between them. You can add UIBarbuttonItem to the UINavigationBar. It even has its own built in back button.

I suggest you look up the marked classes/actions.

  • Are you working with the storyboard? If yes, is it possible that you can show me a screenshot on which i can clearly see your viewcontrollers? – Jan Somers JanS91 May 30 '17 at 10:12
  • i used this with programetically – Sharda Prasad May 30 '17 at 10:13
  • Well, I don't have much info but maybe you could try these options: 1) https://stackoverflow.com/a/27127546/7018180 2) Create a navigation bar in your viewcontroller and add your own barbuttons to it: `UINavigationBar *navbar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)]; //do something like background color, title, etc you self [self.view addSubview:navbar];` – Jan Somers JanS91 May 30 '17 at 10:27