【IOS】iphone6s 3d touch之HelloWorld
来源:互联网 发布:算法精解怎么样知乎 编辑:程序博客网 时间:2024/05/17 08:14
在iphone6s之后苹果加入了3D touch功能,最为常用的功能就是在桌面重按图标可以弹出快捷菜单,那么IOS中如何实现呢?
AppDelegate.m
//// AppDelegate.h//// Created by coooliang on 15/5/8.// Copyright (c) 2015年 coooliang. All rights reserved.//- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{......//3D touch功能添加 if (IS_IOS_9) { UIApplicationShortcutIcon *scanIcon = [UIApplicationShortcutIcon iconWithTemplateImageName:@"scan_3dtouch"]; UIApplicationShortcutItem *scanItem = [[UIApplicationShortcutItem alloc]initWithType:@"scan" localizedTitle:@"扫一扫" localizedSubtitle:@"" icon:scanIcon userInfo:nil]; UIApplicationShortcutIcon *searchIcon = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeSearch]; UIApplicationShortcutItem *searchItem = [[UIApplicationShortcutItem alloc]initWithType:@"search" localizedTitle:@"搜一搜" localizedSubtitle:@"" icon:searchIcon userInfo:nil]; UIApplicationShortcutIcon *shareIcon = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeShare]; UIApplicationShortcutItem *shareItem = [[UIApplicationShortcutItem alloc]initWithType:@"share" localizedTitle:@"分享" localizedSubtitle:@"" icon:shareIcon userInfo:nil]; [[UIApplication sharedApplication]setShortcutItems:@[scanItem,searchItem,shareItem]]; } return YES;}
#pragma mark - ios9 iphone6s 3d touch- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void(^)(BOOL succeeded))completionHandler{ NSString *type = shortcutItem.type; if([@"search"isEqualToString:type]){ }else if([@"scan"isEqualToString:type]){ }else if([@"share"isEqualToString:type]){ }}
只要在AppDelegate中的两个方法中添加以上代码,就可以实现简单的图标3D Touch功能咯,就是这么简单~
0 0
- 【IOS】iphone6s 3d touch之HelloWorld
- iOS 9之3D Touch
- iOS 9 之 3D touch
- iOS开发之3D Touch
- iOS开发-------3D Touch之ApplicationShortcutItem
- iOS之实现3D Touch
- ios 3D Touch
- iOS 3D touch
- iOS 3D Touch
- iOS 3D Touch
- iOS 3D Touch开发
- iOS 3D Touch功能
- iOS 3D touch 开发
- iOS 3D Touch功能
- iOS 3D Touch 简述
- iOS 3D Touch功能
- iOS 3D Touch浅谈
- IOS 3D Touch功能分析
- Jmeter实现webservice的压力测试
- ”南大软院大神养成计划“南昌大学信工学院黄永情
- HTML中<Javascript>与activity之间的交互
- 数组和指针的区别
- Java垃圾回收机制
- 【IOS】iphone6s 3d touch之HelloWorld
- Elasticsearch[2.0] ☞ Java Client API ☞ Percolate API
- 调用照相机和相册功能
- hdoj 1024 Max Sum Plus Plus 【简单dp】
- 蓝桥杯基础练习 回文数
- iOS问题总结
- Adb failed to restart! Make sure the plugin is properly configured.
- excel排序---结构体的排序
- 图论算法基础