我在聚光灯下收到结果,但是当用户点击它时,它只会启动应用程序,我无法选择该特定产品。
如果有人可以帮助我,那将会非常有用!
谢谢!
到目前为止,这是我的代码:
Comment with Line Comment
答案 0 :(得分:1)
您正在检查activityType
是否存在错误值。
从聚光灯下启动应用时,活动类型为CSSearchableItemActionType
,userInfo
包含一个包含产品标识符的键值对CSSearchableItemActionType
。
简单的Objective-C示例:
-(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler
{
if ([userActivity.activityType isEqualToString:CSSearchableItemActionType])
{
NSString *uniqueIdentifier = userActivity.userInfo[CSSearchableItemActivityIdentifier];
// do stuff to show detail for product with uniqueIdentifier
return YES; // because you did handle the activity
}
return NO; // because you did NOT handle the activity
}
Simple Swift示例:
func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Void) -> Bool
{
if userActivity.activityType == CSSearchableItemActionType {
let uniqueIdentifier = userActivity.userInfo[CSSearchableItemActivityIdentifier]
// do stuff to show detail for product with uniqueIdentifier
return true // because you did handle the activity
}
return false // because you did NOT handle the activity
}
答案 1 :(得分:0)
以下检查可以帮助您: