3d touch

二 . 使用

方法1 :

  • 在APPDelegate里面的
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

UIApplicationShortcutIcon *icon1 = [UIApplicationShortcutIcon iconWithTemplateImageName:@“图片名字1”];
UIApplicationShortcutIcon *icon2 = [UIApplicationShortcutIcon iconWithTemplateImageName:@“图片名字2”];

    UIMutableApplicationShortcutItem *item1 = [[UIMutableApplicationShortcutItem alloc]initWithType:@"com.deep1" localizedTitle:@“标题名字1” localizedSubtitle:@“子标题名字1”  icon:icon1 userInfo:nil];
UIMutableApplicationShortcutItem *item2 = [[UIMutableApplicationShortcutItem alloc]initWithType:@"com.deep2” localizedTitle:@"标题名字2” localizedSubtitle:@“子标题名字2”  icon:icon1 userInfo:nil];

    [UIApplication sharedApplication].shortcutItems = @[item1,item2];

}

// 里面实现点击app角标进来时对应事件的处理
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler {
    
    if ([shortcutItem.type isEqualToString:@"com.deep1"]) {
        BaseTabBarController *baseTab = (BaseTabBarController *)_window.rootViewController;
        [baseTab setSelectedIndex:2];
        if ([JCCore is_login]) {
            PersonalNaviController *navc = (PersonalNaviController *)[baseTab.viewControllers objectAtIndex:2];
            UIStoryboard *stor = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
            NameCardViewController *vc = [stor instantiateViewControllerWithIdentifier:@"NameCardViewController"];
            vc.hidesBottomBarWhenPushed = YES;
            vc.enable_transition_animation = YES;
            vc.personalDic = [JCCore get_employee_info];
            [navc pushViewController:vc animated:YES];
        }
    }else if ([shortcutItem.type isEqualToString:@"com.deep2”]) {
// 自己要实现的事情
}
}

你可能感兴趣的:(3d touch)