ram*_*dhi 5 objective-c ios corespotlight
我有一个CSSearchableItem带CSSearchableItemAttributeSet,
CSSearchableItemAttributeSet* attributes = [[CSSearchableItemAttributeSet alloc]initWithItemContentType:(__bridge NSString *)kUTTypeContact];
attributes.keywords = @[keywords];
attributes.title = @"Contact Details";
attributes.displayName = @"Ram Gandhi";
attributes.emailAddresses = @[email];
attributes.phoneNumbers = @[phoneNumber];
attributes.contentDescription = [NSString stringWithFormat:@"%@ \n %@", phoneNumber, email];
attributes.supportsPhoneCall = [NSNumber numberWithBool:YES];
attributes.supportsNavigation = [NSNumber numberWithBool:NO];
attributes.thumbnailData = [self getThumbnailData:contactID];
Run Code Online (Sandbox Code Playgroud)
一切都运行正常,但新行contentDescription没有按预期工作,虽然它没有在UI中显示.
此外,我不确定在kUTTypeContact这里使用的目的和kUTTypeContent工作一样.就我搜索而言,没有关于如何kUTTypeContact在Spotlight搜索中使用的详细文档.
我可以使用其他任何财产以便在单独的行中显示电子邮件和电话号码吗?
这对你来说可能是很晚的答案,但它可以帮助其他人。现在,在使用 swift 4 时,我们可以添加 2 行“contentDescription”,如下所示,
var contentDescription = ""
var arrDescription = ["email","phone"]
for (index,strDesc) in arrDescription.enumerated(){
if index == 0{
contentDescription = strDesc
}else{
contentDescription += """
\(strDesc)
"""
}
}
Run Code Online (Sandbox Code Playgroud)
我还尝试添加两个以上的字符串,但它最多只显示两行,然后它将在第二行末尾显示...。
注意: - 检查“(strDesc)”之前的“空白行”,它不是错误的,它必须在那里显示换行符。
| 归档时间: |
|
| 查看次数: |
472 次 |
| 最近记录: |