简体   繁体   中英

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
                 completion:nil];

Please see https://developer.apple.com/library/ios/documentation/ContactsUI/Reference/CNContactViewController_Class/#//apple_ref/occ/clm/CNContactViewController/viewControllerForNewContact :

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM