美文网首页
iOS 3DTouch

iOS 3DTouch

作者: 静静的coding | 来源:发表于2017-02-16 21:10 被阅读30次

3D Touch,苹果iPhone 6s的新功能

有Peek Pop 两种新手势

实现点击app出现小弹框界面的方法

1.在info.plist中进行设定

2.或者是在appdelegate里面直接进行添加

方法didFinishLaunchingWithOptions中直接添加一下代码

/**\

UIApplicationShortcutIconTypeCompose,//创作

UIApplicationShortcutIconTypePlay,//播放

UIApplicationShortcutIconTypePause,//暂停

UIApplicationShortcutIconTypeAdd,//添加

UIApplicationShortcutIconTypeLocation,位置

UIApplicationShortcutIconTypeSearch,搜索

UIApplicationShortcutIconTypeShare,分享

*/

//当然也可以自己设置图片

//添加快捷启动

UIApplicationShortcutIcon *icon = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeCompose];

UIApplicationShortcutItem *item = [[UIApplicationShortcutItem alloc]initWithType:@"0" localizedTitle:@"1" localizedSubtitle:nil icon:icon userInfo:nil];

UIApplicationShortcutIcon *icon1 = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypePlay];

UIApplicationShortcutItem *item1 = [[UIApplicationShortcutItem alloc]initWithType:@"1" localizedTitle:@"2" localizedSubtitle:nil icon:icon1 userInfo:nil];

UIApplicationShortcutIcon *icon2 = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypePause];

UIApplicationShortcutItem *item2 = [[UIApplicationShortcutItem alloc]initWithType:@"2" localizedTitle:@"3" localizedSubtitle:nil icon:icon2 userInfo:nil];

UIApplicationShortcutIcon *icon3 = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeAdd];

UIApplicationShortcutItem *item3 = [[UIApplicationShortcutItem alloc]initWithType:@"3" localizedTitle:@"3" localizedSubtitle:nil icon:icon3 userInfo:nil];

UIApplicationShortcutIcon *icon4 = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeLocation];

UIApplicationShortcutItem *item4 = [[UIApplicationShortcutItem alloc]initWithType:@"4" localizedTitle:@"3" localizedSubtitle:nil icon:icon4 userInfo:nil];

UIApplicationShortcutIcon *icon5 = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeSearch];

UIApplicationShortcutItem *item5 = [[UIApplicationShortcutItem alloc]initWithType:@"5" localizedTitle:@"3" localizedSubtitle:nil icon:icon5 userInfo:nil];

UIApplicationShortcutIcon *icon6 = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeShare];

UIApplicationShortcutItem *item6 = [[UIApplicationShortcutItem alloc]initWithType:@"6" localizedTitle:@"3" localizedSubtitle:nil icon:icon6 userInfo:nil];

[[UIApplication sharedApplication] setShortcutItems:@[item4,item5,item6]];

3.点击不同的小图标进行的操作是,此方法也是写在appdelegate里面的

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

UINavigationController *nav = (UINavigationController *)self.window.rootViewController;

//也可以直接在当前最外面的Vc上进行跳转

DemoViewController *detailVC = [[DemoViewController alloc] init];

//进行不同界面类型的跳转

switch ([shortcutItem.type integerValue]) {

case 0:

detailVC.titleStr = @"1";

break;

case 1:

detailVC.titleStr = @"2";

break;

case 2:

detailVC.titleStr = @"3";

break;

case 3:

detailVC.titleStr = @"4";

break;

case 4:

detailVC.titleStr = @"5";

break;

case 5:

detailVC.titleStr = @"6";

break;

case 6:

detailVC.titleStr = @"7";

break;

case 7:

detailVC.titleStr = @"8";

break;

default:

break;

}

[nav pushViewController:detailVC animated:YES];

}

4.点击app里面的按钮执行压力感应,一定要执行这两个方法

#pragma mark - UIViewControllerPreviewingDelegate- (UIViewController *)previewingContext:(id)previewingContext viewControllerForLocation:(CGPoint)location {    for (UIView *view in self.tableView.subviews) {        NSString *class = [NSString stringWithFormat:@"%@",view.class];        if ([class isEqualToString:@"UITableViewWrapperView"])        for (UIView *littleView in view.subviews) {            if ([littleView isKindOfClass:[UITableViewCell class]] && CGRectContainsPoint(littleView.frame, location)) {                self.touchCell = (UITableViewCell *)littleView;            }        }    }    previewingContext.sourceRect = self.touchCell.frame;    DemoViewController *detailVC = [[DemoViewController alloc] init];    //一定得是在这个方法里面设置代理    detailVC.delegate = self;    return detailVC;}- (void)previewingContext:(id)previewingContext commitViewController:(UIViewController *)viewControllerToCommit {

[self tableView:self.tableView didSelectRowAtIndexPath:[self.tableView indexPathForCell:self.touchCell]];

}

比如说点击完cell出现的下一集界面就是在这里进行设定的

5.下一级的视图的删除功能需要在下一集的界面里面执行

- (NSArray> *)previewActionItems {

UIPreviewAction *action1 = [UIPreviewAction actionWithTitle:@"删除" style:UIPreviewActionStyleDefault handler:^(UIPreviewAction * _Nonnull action, UIViewController * _Nonnull previewViewController) {

if ([self.delegate respondsToSelector:@selector(deleteWithIndexPath:)]) {

[self.delegate deleteWithIndexPath:1];

}

}];

NSArray *actions = @[action1];

return actions;

}

具体的操作可以使用通知代理等等进行操作

具体的gitHub地址Demo地址

相关文章

  • 3DTouch 使用

    iOS9之后使用3DTouch 3DTouch功能主要分为两大块:主屏幕Icon上的Quick Action;Pe...

  • ios 3DTouch 官方工程OC版

    ios 3DTouch 官方工程OC版 想要看一下 官方 的3DTouch教程,发现例子竟然只有swift版本的,...

  • 怎么给App的某个功能添加桌面快捷方式?

    iOS中给App添加快捷方式的几种方案: 3DTouch,长按App唤起3DTouch菜单,这个同时也可以当做小组...

  • 给App的某个功能添加桌面快捷方式

    iOS中给App添加快捷方式的几种方案: 3DTouch,长按App唤起3DTouch菜单,这个同时也可以当做小组...

  • 详解3DTouch的使用

    3DTouch的简单使用. 介绍 3DTouch是iOS9的时候出来,对硬件也有要求,也就是说只有iPhone6s...

  • iOS开发中添加3DTouch功能

    iOS开发中添加3DTouch功能 在AppDelegate入口类的入口方法- (BOOL)application...

  • 3DTouch_IOS开发与应用

    3-DTouch_IOS 对集成3DTouch的简单讲解 Demo下载地址:https://github.com/...

  • iOS APP开发添加3D Touch

    本文就iOS开发中如何集成3DTouch做下简单的讲解。 开发环境及调试设备:Xcode7或以上,iOS9或以上,...

  • iOS 3DTouch

    一.什么是3DTouch? 效果图: 点击icon: Peek(预览)和Pop(跳至预览的详细界面): 看完这个,...

  • iOS 3DTouch

    1. 3D Touch的主要应用 官方文档给出的应用介绍主要有两块: 1.A user can now press...

网友评论

      本文标题:iOS 3DTouch

      本文链接:https://www.haomeiwen.com/subject/yqghwttx.html