切记,3D_Touch是在iOS 9以后才推出来的,要用这个功能时,一定要进行版本判定,不然在低系统版本上就会造成App闪退。
if ([[UIDevice currentDevice].systemVersion floatValue]>9.0) {
//使用系统图标
//UIApplicationShortcutIcon *icon1 = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeShuffle];
//使用自己的图片
UIApplicationShortcutIcon *icon = [UIApplicationShortcutIcon iconWithTemplateImageName:@"2dCode"];
UIApplicationShortcutItem *item1 = [[UIApplicationShortcutItem alloc]initWithType:@"item1" localizedTitle:@"二维码" localizedSubtitle:nil icon:icon userInfo:nil];
NSArray *array = @[item1];
[UIApplication sharedApplication].shortcutItems = array;
}
//代理方法
-(void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler
{
//这里可以实现界面跳转等方法
if ([shortcutItem.type isEqualToString:@"item1"]) {
NSLog(@"按压了第一个标题");
NSDictionary *dic = @{
@"page": @"WebController",
@"property": @{
@"pUrl": WEB_ERWEIMA,
}
};
[LHPageJumperManager jump2Controller:dic popOther:NO];
}
}
lADPBY0V4vY5eyfNBTbNAu4_750_1334.jpg_620x10000q90g.jpg
网友评论