Aldo Lazuardi Aldo Lazuardi - 2 months ago 20x
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


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