3D touch

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

    // Override point for customization after application launch.

    

    //判断是否支持3D Touch功能

    if (self.window.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable) {

        // 动态添加标签

        UIApplicationShortcutIcon *icon = [UIApplicationShortcutIcon iconWithTemplateImageName:@"扫码图标"];

        UIApplicationShortcutItem *shortItem1 = [[UIApplicationShortcutItem alloc] initWithType:@"扫码" localizedTitle:@"扫码" localizedSubtitle:nil icon:icon userInfo:nil];

        NSArray *shortItems = [[NSArray alloc] initWithObjects:shortItem1, nil];

        NSLog(@"%@", shortItems);

        [[UIApplication sharedApplication] setShortcutItems:shortItems];

    }

    

    return YES;

}

 

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

    if ([shortcutItem.localizedTitle  isEqual: @"扫码"]) {

        

        NSLog(@"打开扫码界面");

        

        ViewController *controller = (ViewController *)self.window.rootViewController;

        [controller goScanne];

        

        return;

    }

}

 

其他链接:

http://blog.csdn.net/a416863220/article/details/51217465

 

 

 

posted @ 2017-03-13 11:48  Da雪山  阅读(187)  评论(0编辑  收藏  举报