ios9 3D Touch 实现

来源:互联网 发布:调度数据网通信维护 编辑:程序博客网 时间:2024/05/01 22:13
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ if (IOS_9_OR_LATER) {        UIApplicationShortcutIcon *firstItemIcon = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeSearch];                UIMutableApplicationShortcutItem *firstItem = [[UIMutableApplicationShortcutItem alloc]initWithType:@"FirstSearch"                                                                                             localizedTitle:@"搜索"                                                                                          localizedSubtitle:nil                                                                                                       icon:firstItemIcon                                                                                                   userInfo:nil];                //    UIApplicationShortcutIcon *secondItemIcon = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeAdd];        //        //    UIMutableApplicationShortcutItem *secondItem = [[UIMutableApplicationShortcutItem alloc]initWithType:@"second"        //                                                                                          localizedTitle:@"第二个item"        //                                                                                       localizedSubtitle:nil        //                                                                                                    icon:secondItemIcon        //                                                                                                userInfo:nil];                application.shortcutItems = @[firstItem];            }

-(void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler{        UINavigationController *nav =(UINavigationController *) [UIApplication sharedApplication].keyWindow.rootViewController;        if ([shortcutItem.type isEqual:@"FirstSearch"]) {                NSLog(@"跳转到firstItem界面");                CreateVC(SearchHomeVC);//        [nav pushViewController:vc animated:NO];        //    }else if([shortcutItem.type isEqual:@"second"]){//        //        NSLog(@"跳转到secondItem界面");        //        secondItemView *second = [[secondItemView alloc]init];//        //        [nav pushViewController:second animated:YES];    }}

0 0