iOS 9 spotlight搜索 3DTouch

本文介绍如何在iOS应用中实现Spotlight搜索功能及3D Touch快捷操作,包括配置可搜索项、处理用户活动及定义3D Touch快捷菜单。
部署运行你感兴趣的模型镜像

1 spotlight搜索

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    

    [self saveData];

}

- (void)saveData{

    

        NSMutableArray *seachableItems = [NSMutableArray new];

    

        CSSearchableItemAttributeSet *attributeSet = [[CSSearchableItemAttributeSet alloc] initWithItemContentType:@"views"];

        attributeSet.title = @"奇奇爱运动";

       // attributeSet.contentDescription = [NSString stringWithFormat:NSLocalizedString(@"a easy way to open %@", nil),@"objc"];

        UIImage *thumbImage = [UIImage imageNamed:@"Icon_default"];

        attributeSet.thumbnailData = UIImagePNGRepresentation(thumbImage);//beta 1 there is a bug

        CSSearchableItem *item = [[CSSearchableItem alloc] initWithUniqueIdentifier: @"奇奇爱运动"                                                                                                                                    domainIdentifier:@"com.kdanmobile.CoreSpotlightDemo"                                                                                                        attributeSet:attributeSet];

        [seachableItems addObject:item];

    

    [[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:seachableItems

                                                   completionHandler:^(NSError * __nullable error) {                                                              if (!error)

                                                       NSLog(@"%@",error.localizedDescription);

                                                   }];

    //[CSSearchableIndex defaultSearchableIndex] deleteSearchableItemsWithIdentifiers: completionHandler:<#^(NSError * _Nullable error)completionHandler#>];

}


重写方法

- (BOOL)application:(nonnull UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray * __nullable))restorationHandler{

    

    NSString *idetifier = userActivity.userInfo[@"kCSSearchableItemActivityIdentifier"];

    

    UINavigationController *navigationController = (UINavigationController *)self.courseVC.navigationController;

    [navigationController popToRootViewControllerAnimated:YES];

    [self.courseVC showWithNewAPP:idetifier];

    //[self.courseVC showAnAppDetailViewWithappKey:@"1040081628"];

    

    return YES;

    

}


2 新特性 3DTouch

APPDelegate中重写方法即可

-(void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler{

    NSString *type = shortcutItem.type;

    if ([type isEqualToString:@"com.adc.itemSetting"]) {

        

        [self.courseVC gotoSettingview];

    }else if([type isEqualToString:@"com.adc.itemSearch"]){

        

        [self.courseVC showWithNewAPP:@"com.adc.itemFreeLimited"];

    }e

}


主页显示的quickly action 可以在info.plist 文件中自定义静态的 



也可以动态定义

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  

     UIApplicationShortcutItem *shortItem1 = [[UIApplicationShortcutItem alloc] initWithType:@"打开" localizedTitle:@"打开"];

    UIApplicationShortcutItem *shortItem2 = [[UIApplicationShortcutItem alloc] initWithType:@"弹框" localizedTitle:@"弹框"];

    NSArray *shortItems = [[NSArray alloc] initWithObjects:shortItem1, shortItem2, nil];

    NSLog(@"%@", shortItems);

    [[UIApplication sharedApplication] setShortcutItems:shortItems];


}

您可能感兴趣的与本文相关的镜像

Stable-Diffusion-3.5

Stable-Diffusion-3.5

图片生成
Stable-Diffusion

Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

内容概要:本文围绕“基于数据驱动的 Koopman 算子的递归神经网络模型线性化,用于纳米定位系统的预测控制研究”展开,提出了一种结合Koopman算子理论与递归神经网络(RNN)的数据驱动建模方法,旨在对非线性纳米定位系统进行有效线性化建模,并实现高精度的模型预测控制(MPC)。该方法利用Koopman算子将非线性系统映射到高维线性空间,通过递归神经网络学习系统的动态演化规律,构建可解释性强、计算效率高的线性化模型,进而提升预测控制在复杂不确定性环境下的鲁棒性与跟踪精度。文中给出了完整的Matlab代码实现,涵盖数据预处理、网络训练、模型验证与MPC控制器设计等环节,具有较强的基于数据驱动的 Koopman 算子的递归神经网络模型线性化,用于纳米定位系统的预测控制研究(Matlab代码实现)可复现性和工程应用价值。; 适合人群:具备一定控制理论基础和Matlab编程能力的研究生、科研人员及自动化、精密仪器、机器人等方向的工程技术人员。; 使用场景及目标:①解决高精度纳米定位系统中非线性动态响应带来的控制难题;②实现复杂机电系统的数据驱动建模与预测控制一体化设计;③为非线性系统控制提供一种可替代传统机理建模的有效工具。; 阅读建议:建议结合提供的Matlab代码逐模块分析实现流程,重点关注Koopman观测矩阵构造、RNN网络结构设计与MPC控制器耦合机制,同时可通过替换实际系统数据进行迁移验证,深化对数据驱动控制方法的理解与应用能力。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值