GithubHelp home page GithubHelp logo

frankswu / 3dtouch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kennyhito/3dtouch

0.0 1.0 0.0 111 KB

主要介绍Home Screen Quick Actions,即通过主屏幕的应用Icon,我们可以用3DTouch呼出一个菜单,进行快速定位应用功能模块相关功能的开发。

Objective-C 100.00%

3dtouch's Introduction

概述

  • 本工程主要是利用iOS 的Objective-C开发的技术要点汇总;
  • 涵盖了开发中踩坑的原因,以及填坑的技术分享;
  • 抛砖引玉,取长补短,希望能够提供一点思路,避免少走一些弯路。

功能

  • 主要介绍Home Screen Quick Actions,即通过主屏幕的应用Icon,我们可以用3DTouch呼出一个菜单,进行快速定位应用功能模块相关功能的开发。

要求

  • iOS 8+
  • Xcode 8.0+

期待

  • 如果在使用过程中遇到BUG,希望你能Issues我,谢谢(或者尝试下载最新的代码看看BUG修复没有)。
  • 如果在使用过程中发现有更好或更巧妙的实用技术,希望你能Issues我,我非常为该项目扩充更多好用的技术,谢谢。
  • 如果通过该工程的使用,对您在开发中有一点帮助,码字不易,还请点击右上角"★★★★★"按钮,谢谢。

代码实现

  • AppDelegate.m
//检测App启动方式
-(void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler{

    if([shortcutItem.type isEqualToString:@"ONE"]){
        //发送通知
        [[NSNotificationCenter defaultCenter]postNotificationName:@"ONES" object:@"ONES"];

    }else if([shortcutItem.type isEqualToString:@"TWO"]){
        //发送通知
        [[NSNotificationCenter defaultCenter]postNotificationName:@"TWOS" object:@"TWOS"];
    }
}
  • ViewController.m
//注册通知
- (void)registerNotification{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onesNotification) name:@"ONES" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(twpsNotification) name:@"TWOS" object:nil];
}
//动态添加标签
NSArray * titleArr = @[@"分享App",@"首页"];
NSArray * typeArr = @[@"ONE",@"TWO"];
NSMutableArray * dataArr = [[NSMutableArray alloc]init];
for (int i = 0; i<titleArr.count; i++) {
    // 创建标签的ICON图标。
    UIApplicationShortcutIcon *icon;
    if (i==0) {
        icon = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeShare];
    }else if(i==1){
        icon = [UIApplicationShortcutIcon iconWithType:UIApplicationShortcutIconTypeHome];
    }
    // 创建一个标签,并配置相关属性。
    UIApplicationShortcutItem *item = [[UIApplicationShortcutItem alloc] initWithType:typeArr[i] localizedTitle:titleArr[i] localizedSubtitle:nil icon:icon userInfo:nil];
    [dataArr addObject:item];
}
// 将标签添加进Application的shortcutItems中。
[UIApplication sharedApplication].shortcutItems = dataArr;
//实现通知事件
/**跳转页面一*/
- (void)onesNotification{
    [self.navigationController pushViewController:_oneVC animated:YES];
}
/**跳转页面二*/
- (void)twpsNotification{
    [self.navigationController pushViewController:[twoViewController new] animated:YES];
}

效果图

   

3dtouch's People

Contributors

kennyhito avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.