ios使用3dD Touch Screen Short Cut

来源:互联网 发布:淘宝客返现 编辑:程序博客网 时间:2024/06/05 17:13

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

{

if (IOS9_OR_LATER) {

        [selfshortCut];

    }

}


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

{

    if ([shortcutItem.typeisEqualToString:@"searchItem"]) {       

 SearchViewController *room = [[SearchViewController allocinit];

            [baseNav pushViewController:room animated:YES];

    }

   if ([shortcutItem.type isEqualToString:@"icon_recharge"]) {       

 RechargeViewController *room = [[RechargeViewController allocinit];

             [baseNav pushViewController:room animated:YES];

    }



//3d touch screen short cut

- (void) shortCut

{

    NSArray * typeArray =@[@"searchItem",@"rechargeItem"];//key类型

    NSArray * titleArray =@[@"搜索",@“充值”];//标题

    //图标名字,项目资源中的图标名称

    NSArray * imageNameArray =@[@"icon_search",@"icon_recharge"];

    NSMutableArray * itemArray = [[NSMutableArrayalloc] init];

    for (int i=0; i<typeArray.count; i++) {

        UIApplicationShortcutIcon * icon = [UIApplicationShortcutIconiconWithTemplateImageName:imageNameArray[i]];

        UIMutableApplicationShortcutItem * item = [[UIMutableApplicationShortcutItemalloc] initWithType:typeArray[i]localizedTitle:titleArray[i] localizedSubtitle:@""icon:icon userInfo:nil];

        [itemArray addObject:item];

    }

    [UIApplicationsharedApplication].shortcutItems = itemArray;

}




1 0
原创粉丝点击