您的位置:首页 > 移动开发 > IOS开发

ios使用3dD Touch Screen Short Cut

2016-01-25 15:52 323 查看
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions
{
if (IOS9_OR_LATER) {

[self
shortCut];
}
}

- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem
*)shortcutItem completionHandler:(void(^)(BOOL succeeded))completionHandler
{
if ([shortcutItem.type
isEqualToString:@"searchItem"]) {
SearchViewController *room = [[SearchViewController alloc] init];
[baseNav pushViewController:room animated:YES];
}

if ([shortcutItem.type isEqualToString:@"icon_recharge"])
{
RechargeViewController *room = [[RechargeViewController alloc] init];
[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 = [[NSMutableArray
alloc] init];
for (int i=0; i<typeArray.count;
i++) {
UIApplicationShortcutIcon * icon = [UIApplicationShortcutIcon
iconWithTemplateImageName:imageNameArray[i]];
UIMutableApplicationShortcutItem * item = [[UIMutableApplicationShortcutItem
alloc] initWithType:typeArray[i]
localizedTitle:titleArray[i]
localizedSubtitle:@""
icon:icon userInfo:nil];
[itemArray addObject:item];
}
[UIApplication
sharedApplication].shortcutItems = itemArray;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: