Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 重复项目显示在聚光灯中,缩略图不显示_Ios_Spotlight_Nsuseractivity - Fatal编程技术网

Ios 重复项目显示在聚光灯中,缩略图不显示

Ios 重复项目显示在聚光灯中,缩略图不显示,ios,spotlight,nsuseractivity,Ios,Spotlight,Nsuseractivity,我试图同时使用nsserActivity、核心聚光灯API和web标记 因此,根据中给出的建议 如果您使用所有三个API,那么使用 作为uniqueIdentifier的值的相关网页, relatedUniqueIdentifier和webpageURL 以下是我创建项目的方式: NSUserActivity *activity = [[NSUserActivity alloc] initWithActivityType:@"com.test.product"]; activity.title

我试图同时使用
nsserActivity
核心聚光灯API
和web标记

因此,根据中给出的建议

如果您使用所有三个API,那么使用 作为uniqueIdentifier的值的相关网页, relatedUniqueIdentifier和webpageURL

以下是我创建项目的方式:

NSUserActivity *activity = [[NSUserActivity alloc] initWithActivityType:@"com.test.product"];
activity.title = self.detailModel.title;
activity.userInfo = @{ @"id" : self.detailModel.productId };
activity.eligibleForHandoff = NO;
activity.eligibleForPublicIndexing = YES;
activity.eligibleForSearch = YES;
activity.webpageURL = [NSURL URLWithString:[self shareUrl]];

activity.contentAttributeSet.contentDescription = self.detailModel.proDesc;
activity.contentAttributeSet.title = self.detailModel.title;
activity.contentAttributeSet.thumbnailData = UIImagePNGRepresentation(image);
activity.contentAttributeSet.relatedUniqueIdentifier = [self shareUrl];

CSSearchableItemAttributeSet *attrSet = [[CSSearchableItemAttributeSet alloc] initWithItemContentType:(NSString *)kUTTypeURL];
attrSet.title = self.detailModel.title;
attrSet.contentDescription = self.detailModel.proDesc;
attrSet.thumbnailData = activity.contentAttributeSet.thumbnailData;
attrSet.relatedUniqueIdentifier = [self shareUrl];

CSSearchableItem *searchableItem = [[CSSearchableItem alloc] initWithUniqueIdentifier:[self shareUrl] domainIdentifier:@"com.test.product" attributeSet:attrSet];
[[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:@[ searchableItem ] completionHandler:^(NSError *_Nullable error) {
    if (error) {
        DDLogError(@"%@", error.localizedDescription);
    } else {
        DDLogInfo(@"Core Spotlight indexed");
    }
  }];
  }
}];

self.systemUserActivity = activity;
[self.systemUserActivity becomeCurrent];
但当我试图在聚光灯下搜索时,有两个问题:

  • 将显示重复的项目,一个来自活动,另一个来自聚光灯索引

  • 这两个项目仅显示应用程序图标,而不是我设置的图像