3D Touch开发
来源:互联网 发布:印度 人口 知乎 编辑:程序博客网 时间:2024/05/22 15:10
在程序入口的代理方法里面执行下面代码???
//3D Touch 分为重压和轻压手势, 分别称作POP(第一段重压)和PEEK(第二段重压), 外面的图标只需要POP即可.
//POP手势图标初始化//使用系统自带图标
UIApplicationShortcutIcon *icon1 = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeAdd];
UIApplicationShortcutIcon *icon2 = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeShare];
//使用自己的图片
// UIApplicationShortcutIcon *icon = [UIApplicationShortcutIcon iconWithTemplateImageName:@"自己的图片"];
UIApplicationShortcutItem *item1 = [[UIApplicationShortcutItem alloc]initWithType:@"item1" localizedTitle:@"标题1" localizedSubtitle:nil icon:icon1 userInfo:nil];
UIApplicationShortcutItem *item2 = [[UIApplicationShortcutItem alloc]initWithType:@"item2" localizedTitle:@"标题2" localizedSubtitle:nil icon:icon2 userInfo:nil];
NSArray *array = @[item1,item2];
[UIApplication sharedApplication].shortcutItems = array;
点击图标之后会从这个入口进入App:
#pragma mark - 3DTouch触发的方法
-(void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler
{
//这里可以实现界面跳转等方法
if ([shortcutItem.type isEqualToString:@"item1"]) {
SFSafariViewController *sv = [[SFSafariViewController alloc]initWithURL:[NSURL URLWithString:@"http://weibo.com/p/1005055844400745/home?from=page_100505_profile&wvr=6&mod=data&is_all=1#place"]];
_window.rootViewController = sv;
NSLog(@"按压了第一个标题");
}
else if ([shortcutItem.type isEqualToString:@"item2"])
{
ViewController *vc = [[ViewController alloc]init];
_window.rootViewController = vc;
NSLog(@"按压了第二个标题");
}
}
然后在处理逻辑!!!
PEEK(第二段重压),
//注册代理
[self registerForPreviewingWithDelegate:self sourceView:self.view];
并遵守协议:UIViewControllerPreviewingDelegate
-(void)previewingContext:(id<UIViewControllerPreviewing>)previewingContext commitViewController:(UIViewController *)viewControllerToCommit
{
//固定这么写
[self showViewController:viewControllerToCommit sender:self];
}
-(UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location
{
//location就是重压点坐标,如果按压点在label上执行以下方法
if (location.x > 100 && location.x < 200 && location.y > 100 && location.y < 200) {
SFSafariViewController *mySV = [[SFSafariViewController alloc]initWithURL:[NSURL URLWithString:URL]];
//第一次按压时,弹出的窗口尺寸,再次按压则跳转到mySV
mySV.preferredContentSize = CGSizeMake(0, 400);
previewingContext.sourceRect = _weiboLabel.frame;//设置高亮区域
return mySV;
}
return nil;
}
- 3D Touch开发
- 3D Touch开发
- iOS 3D Touch开发
- iOS 3D touch 开发
- iOS9-3D Touch开发
- iOS开发之3D Touch
- iOS9 3D touch 适配开发
- 3D Touch开发初体验.
- iOS开发 3D-touch使用
- 3D Touch开发初体验
- iOS开发-------3D Touch之ApplicationShortcutItem
- IOS 3D Touch 开发教程
- iOS 3D Touch 开发 实战
- iOS-3D touch相关开发
- iOS 3D Touch开发介绍
- iOS9 3D touch 适配开发
- 3D touch — ios9新特新开发
- iOS开发-3D Touch简要总结
- storm 文档(3)----入门指导
- GitHub Android Librarys Top 100 简介
- 如何安装Yaf框架?
- Spring mvc拦截器实现登录验证拦截
- Android实现数据存储技术
- 3D Touch开发
- Codeforces Round #338 (Div. 2)B. Longtail Hedgehog(DP)
- 蓝桥杯 算法训练 Lift and Throw
- tomcat6.0实现https安全访问
- javacript基础2
- jQuery操作select下拉框的text值和value值的方法
- 1091. Acute Stroke(30)
- Android中静态成员变量的生命周期
- storm文档(4)----开发环境环境搭建