Aldo Lazuardi Aldo Lazuardi - 4 years ago 454
iOS Question

preload/show data in CNContactViewController (swift)

Could we show data in ios editor/CNContactViewController instead only show blank textfields?

for example, when I open CNContactViewController I want the name to be filled before user type anything

Answer Source

Yes, It is possible. Using viewControllerForNewContact: method of CNContactViewController, you can pass a CNContact object.

So in order to show name as filled in view, create a contact object with name and pass to viewControllerForNewContact:

CNMutableContact *pNewContact          = [[CNMutableContact alloc] init];
pNewContact.givenName                  = @"My Name";
CNContactViewController *pNewContactVC = [CNContactViewController viewControllerForNewContact:pNewContact];
UINavigationController *pNavController = [[UINavigationController alloc] initWithRootViewController:pNewContactVC];
[self presentViewController:pNavController animated:YES

Please see

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download