请检查所附图片:
我正在使用标准的以下代码生成VCF文件:
- (NSString *) saveContactToDocumentDirectory:(NSMutableArray *)Contact{
NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString * VCardPath = [documentsDirectory stringByAppendingString:@"/vcard.vcf"];
NSArray *array = [[NSArray alloc] initWithArray:Contact];
NSError *error;
NSData *data = [CNContactVCardSerialization dataWithContacts:array error:&error];
[data writeToFile:VCardPath atomically:YES];
return VCardPath;
}
它显示了错误的名称,例如 ms-1aaL5g ,而不是 Daniel Higgins
仅在iOS 12中会出现此问题。