【问题标题】:Newline formatting is not supported in contentDescription property of CSSearchableItemAttributeSetCSSearchableItemAttributeSet 的 contentDescription 属性不支持换行格式
【发布时间】:2016-12-16 10:33:35
【问题描述】:

我有一个CSSearchableItemCSSearchableItemAttributeSet

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];

一切正常,但contentDescription 中的换行符没有按预期工作,尽管它没有显示在 UI 中。

我也不确定在这里使用kUTTypeContact 的目的,因为kUTTypeContent 可以完成这项工作。据我搜索,没有关于如何在 Spotlight 搜索中使用kUTTypeContact 的详细文档。

我可以使用任何其他属性来在不同的行中显示电子邮件和电话号码吗?

【问题讨论】:

  • 以前的,iOS10好像已经停止工作了。你有没有运气解决这个问题?
  • Nope.. 就目前而言,我们必须使用适合我们需要的 ItemContentType 和属性,以便将其呈现在其默认 UI 中。
  • 我们有关于每个 ItemContentType 如何呈现的文档吗?他们中的任何一个都允许多行描述吗?
  • 我在这里使用了 kUTTypeMP3 并尝试了“描述音乐”中的一些道具,developer.apple.com/reference/corespotlight/…
  • 我使用了音乐流派和艺术家键来获得第二行。有什么办法可以上三线?我有大部分钥匙,但没有

标签: ios objective-c corespotlight


【解决方案1】:

这对你来说可能是很晚的答案,但它可以帮助其他人。现在,在使用 swift 4 时,我们可以添加 2 行“contentDescription”,如下所示,

var contentDescription = ""
var arrDescription = ["email","phone"]
for (index,strDesc) in arrDescription.enumerated(){
    if index == 0{
        contentDescription = strDesc
    }else{
        contentDescription += """

        \(strDesc)
        """
    }
}

我也尝试添加两个以上的字符串,但它最多只显示两行,然后它会在第二行的末尾显示 ...。

注意:-检查“(strDesc)”之前的“空行”,不是错误,它必须在那里显示换行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-04
    • 1970-01-01
    • 1970-01-01
    • 2017-08-18
    • 2011-06-10
    • 1970-01-01
    • 2021-11-27
    • 2021-12-29
    相关资源
    最近更新 更多