1.3d-touch Brief Introduction
3d-touch is the iphone 6s launch of a new way to let you interact with the mobile phone. This time, the IPhone will be able to sense the intensity you press on the screen. In addition to the familiar Multi of taps, swipes, two-finger closures? In addition to touch gestures, 3D Touch brings Peek and Pop, which opens up new dimensions for the IPhone's experience. And, when you use 3D touch, the IPhone will feel a little bit, so you can not only see the effect of pressing the screen, but also feeling it.
3d-touch contains 3 feature functions, pressure sensing (press sensitivity), peek and pop gestures, shortcuts (quick Actions)
2. If you have the emulator support 3d-touch
currently the official documentation does not support 3d-touch and can be sbshortcutmenusimulator(click to download) with GitHub's Open source project.
Easy to install and use
- Installation
git clone https://github.com/deskconnect/sbshortcutmenusimulator.gitCD Sbshortcutmenusimulatormake
- After installation, perform the following methods in the Sbshortcutmenusimulator directory
Xcrun simctl Spawn booted launchctl debug System/com.apple.springboard--environment dyld_insert_libraries= $PWD/ Sbshortcutmenusimulator.dylibxcrun simctl Spawn booted launchctl stop Com.apple.SpringBoard
- Use
' com.x.x ' is the bundle ID of the program, the ID can be arbitrarily specified
' com.xxx.xxx ' 127.0. 0.1 8000
3. Quick Actions2 method of suitable formulations
1. Static definition
Static definition of commonly used key:
Uiapplicationshortcutitemtype //(must be used) to differentiate the classification with other quick options uiapplicationshortcutitemtitle //(must be used) Quick Options Display Title Uiapplicationshortcutitemsubtitle //Quick Options Display sub-title Uiapplicationshortcutitemicontype //Picture type is provided by the system, Approximately 29 types of uiapplicationshortcutitemiconfile// custom icons are available Uiapplicationshortcutitemuserinfo //Additional information ( Nsdictionary)
Static settings are defined in the Info.plist file
<key>UIApplicationShortcutItems</key> <array> <dict> <key>uiapplication Shortcutitemicontype</key> <string>uiapplicationshortcuticontypebookmark</string> <key>UIApplicationShortcutItemTitle</key> <string> Open the last book read </string> <key>UIApplicationShortcutItemType</key> <string>3dtouchopenbookitem</string> <key>UIApplicationShortcutItemUserInfo</key> <dict> <key> ;shorcutkey</key> <string>shorcutvalue</string> </dict> </dict> <dict> <key>uiapplicationshortcutitemicon Type</key> <string>uiapplicationshortcuticontypesearch</string> <key>UIApplicationShortcutItemTitle</key> <string> Search Bookshelf </string> <key>UIApplicationShortcutItemType</key> <string>3dtouchsearchitem</string> </dict> </array>
2. Dynamic definition
- (void) Initapplication3dtouch: (UIApplication *) Application {nsmutabledictionary*userinfo =[[Nsmutabledictionary alloc] init]; [UserInfo setobject:@"haha"Forkey:@"haha"]; //Customize to get local pictures and pass some parametersUimutableapplicationshortcutitem *itemtest = [[Uimutableapplicationshortcutitem alloc] Initwithtype:@"3"Localizedtitle:@"title"Localizedsubtitle:@"subtitle"Icon:[uiapplicationshortcuticon Iconwithtemplateimagename:@"Local Pictures"] Userinfo:userinfo]; //Open the last book I readUiapplicationshortcuticon *openbook =[Uiapplicationshortcuticon Iconwithtype:uiapplicationshortcuticontypebookmark]; Uimutableapplicationshortcutitem*itemopenbook = [[Uimutableapplicationshortcutitem alloc] Initwithtype:@"2"Localizedtitle:@"Open the last book you read"]; Itemopenbook.icon=OpenBook; //Find a bookUiapplicationshortcuticon *searchbook =[Uiapplicationshortcuticon Iconwithtype:uiapplicationshortcuticontypesearch]; Uimutableapplicationshortcutitem*itemsearchbook = [[Uimutableapplicationshortcutitem alloc] Initwithtype:@"1"Localizedtitle:@"Search Bookshelves"]; Itemsearchbook.icon=Searchbook; //Application.shortcutitems =@[itemtest, Itemopenbook, Itemsearchbook];}
3. Responding to Quick actions events
- (void) Application: (UIApplication *) application Performactionforshortcutitem: (Uiapplicationshortcutitem *) ShortcutItem Completionhandler: (void(^) (BOOL)) Completionhandler {if([Shortcutitem.type isequaltostring:@"1"]) {NSLog (@"Search Bookshelves"); } Else if([Shortcutitem.type isequaltostring:@"3"]) {nsdictionary*dict =Shortcutitem.userinfo; NSLog (@"Dict to pass over the parameters"); }}
3. Notes
1. Shortcut tags can create up to four, both static and dynamic. Static will be displayed in front of the dynamic
2. Static can be displayed in the case of the program does not open, dynamic can not
3. about how to dynamically remove dynamically added quick Actions
Application.shortcutitems = nil; Try it, you can remove the dynamic quick action in this way
If you do not see this article in the wb145230 Blog Park, please click here to view the original.
3d-touch Home screen Quick Actions use