简体   繁体   English

在CNContactViewController(swift)中预加载/显示数据

[英]preload/show data in CNContactViewController (swift)

Could we show data in ios editor/CNContactViewController instead only show blank textfields? 我们可以在ios编辑器/ CNContactViewController中显示数据,而只显示空白文本字段吗?

for example, when I open CNContactViewController I want the name to be filled before user type anything 例如,当我打开CNContactViewController时,我希望在用户输入任何内容之前填充名称

Yes, It is possible. 对的,这是可能的。 Using viewControllerForNewContact: method of CNContactViewController, you can pass a CNContact object. 使用CNContactViewController的viewControllerForNewContact:方法,您可以传递CNContact对象。

So in order to show name as filled in view, create a contact object with name and pass to viewControllerForNewContact: 因此,为了在视图中显示名称,请创建一个带有名称的联系人对象并传递给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 : 请参阅https://developer.apple.com/library/ios/documentation/ContactsUI/Reference/CNContactViewController_Class/#//apple_ref/occ/clm/CNContactViewController/viewControllerForNewContact

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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