首页 > 代码库 > 3D touch

3D touch

<style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #1d9421 } p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; min-height: 21.0px } p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #703daa } p.p5 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #6122ae } p.p6 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #3d1d81 } p.p7 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #c32275 } span.s1 { } span.s2 { color: #c32275 } span.s3 { color: #6122ae } span.s4 { color: #000000 } span.s5 { font: 18.0px "PingFang SC" } span.s6 { color: #539aa4 } span.s7 { color: #3d1d81 } span.s8 { color: #c91b13 } span.s9 { font: 18.0px "PingFang SC"; color: #c91b13 } span.s10 { color: #703daa } span.s11 { color: #3c828c } span.s12 { color: #294c50 }</style>

- (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

 

 

 

3D touch