<span id="Label3"></p><span id="OSC_h2_1"><span id="OSC_h2_1"></span></span>New Touch Experience--ios9 's 3D touch<br> <span id="OSC_h3_2"><span id="OSC_h3_2"></span></span>first, Introduction<br> <p><p><span style="font-size: 16px;">After the advent of iphone6s, many of the fruit powders rushed to experience the extra dimension interaction that 3D touch brings to the user, a design called 3D touch, which, in principle, adds a sense of pressure that makes different user interactions by distinguishing between taps and presses.</span><br></p></p> <span id="OSC_h3_3"><span id="OSC_h3_3"></span></span><span style="font-size: 18px;"><span style="font-size: 18px;">second, Learn and test 3D Touch on the simulator</span></span><span style="font-size: 16px;"><span style="font-size: 16px;"><br></span></span> <p><p><span style="font-size:18px"> </span> <span style="font-size: 16px;">3D Touch</span> <span style="font-size:18px">is a very new design, but Apple Docs has a message:</span></p></p> <blockquote> <blockquote> <ul> <li><p><br></p></li> <li><p>With Xcode 7.0 your must develop on a device that supports 3D Touch. Simulator in Xcode 7.0 does isn't support 3D Touch.</p></li> </ul> <p><br></p> </blockquote> </blockquote> <p><p><span style="font-size: 16px;">See this sentence heart is not half cold, yes, Xcode7 is supported by 3D Touch development, But the simulator does not support this gesture, we can only learn and test on the real machine, but in the IT world, there is no shortage of people to save the world, Someone on GitHub has provided us with a plugin that allows us to test the effects of 3D touch on the simulator:</span><br></p></p> <p><p><span style="font-size: 16px;">Git address: https://github.com/DeskConnect/SBShortcutMenuSimulator.</span></p></p> <span id="OSC_h4_4"><span id="OSC_h4_4"></span></span><span style="font-size: 16px;"><span style="font-size: 16px;">attached. sbshortcutmenusimulator Installation and use<br></span></span> <p><p><span style="font-size: 16px;">In fact, the installation and use do not need to introduce, git home page is very clear, here in the record again, only one point to note, if you like me, the computer is equipped with Xcode6 and Xcode7 two versions, the Xcode compilation path, need to make a change.<br></span></p></p> <p><p><span style="font-size: 16px;">Installation:<br></span></p></p> <p><p><span style="font-size: 16px;">Run the following command once in the Terminal:</span></p></p> <pre class="brush:shell;toolbar: true; auto-links: false;"><pre class="brush:shell;toolbar: true; auto-links: false;">git clone Https://github.com/DeskConnect/SBShortcutMenuSimulator.gitcd Sbshortcutmenusimulatormake</pre></pre> <p><p><span style="font-size: 16px;">If you have more than one version of Xcode in your computer, do the following first, and if you have only Xcode7, you can skip</span><br></p></p> <pre class="brush:shell;toolbar: true; auto-links: false;"><pre class="brush:shell;toolbar: true; auto-links: false;">sudo xcode-select-switch/applications/xcode2.app/contents/developer/</pre></pre> <p><p><span style="font-size: 16px;">Note: The above command, Xcode2.app is your computer's Xcode name, here to pay special attention, if there are spaces in the name, need to modify, the space is removed, otherwise it will affect the execution of the Command.</span><br></p></p> <p><p><span style="font-size: 16px;">After that, perform the following actions in the Sbshortcutmenusimulator directory:</span></p></p> <pre class="brush:shell;toolbar: true; auto-links: false;"><pre class="brush:shell;toolbar: true; auto-links: false;">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</pre></pre> <p><p><span style="font-size: 16px;"></span><span style="font-size: 16px;">If there is no error, we can simulate the effect of 3D touch on the simulator by sending a message to the specified port:</span><br></p></p> <pre class="brush:shell;toolbar: true; auto-links: false;"><pre class="brush:shell;toolbar: true; auto-links: false;">echo ' com.apple.mobilecal ' | NC 127.0.0.1 8000</pre></pre> <p><p><span style="font-size: 16px;">Where com.apple.mobilecal is the bundle ID of the app, if you want to test our app, change it to our App's bundleid, The example application above is the system calendar, and you can see the effect of the emulator as Follows:</span><br></p></p> <p><p><span style="font-size: 16px;"></span></p></p> <span id="OSC_h3_5"><span id="OSC_h3_5"></span></span><span style="font-size: 16px;"><span style="font-size: 16px;"> <span style="font-size: 18px;">three, 3D Touch Main applications</span><br></span></span> <p><p><span style="font-size: 18px;"><span style="font-size: 16px;">There are two main applications presented in this document:</span><br></span></p></p> <blockquote> <blockquote> <p><span style="font-size: 18px;"><span style="font-size: 16px;"></span></span></p> <ul> <li><p>1.A user can now press your Home screens icon to immediately access functionality provided by your app.</p></li> <li><p>2.Within your app, A user can now press views to see previews of additional content and gain accelerated access to feature S.</p></li> </ul> <p><br></p> </blockquote> </blockquote> <p><p><span style="font-size: 16px;">The first part of the application is that we can go directly to the Application's response function module via 3D gesture, on the home screen app Icon. This feature, like our calendar example above, will show a menu next to the icon and click on the menu to access the corresponding function unit.<br></span></p></p> <p><p><span style="font-size: 16px;">I personally understand that this feature, the push message feature plus the extended today feature of the iOS8 rollout, these three mechanisms make iOS apps incredibly flexible and user-friendly, without the time cost of looking for the ability to quickly use what they need.<br></span></p></p> <p><p><span style="font-size: 16px;">The second part is an optimization of the app that allows users to preview some preloaded information on the view via 3D touch gestures, which makes the app more concise and Interactive.<br></span></p></p> <span id="OSC_h3_6"><span id="OSC_h3_6"></span></span><span style="font-size: 16px;"><span style="font-size: 16px;"> <span style="font-size: 18px;">four, 3D touch three major modules</span><br></span></span> <p><p><span style="font-size: 18px;">the <span style="font-size: 16px;">3D Touch feature in our app is mainly divided into the following three modules:</span><br></span></p></p> <span id="OSC_h4_7"><span id="OSC_h4_7"></span></span><span style="font-size: 18px;"><span style="font-size: 18px;"> <span style="font-size: 16px;">1. Home screen Quick Actions<br></span></span></span> <p><p><span style="font-size: 18px;"><span style="font-size: 16px;">Using the Home Screen app icon, we can use 3D touch to call out a menu, to quickly locate the Application function module related function development. such as the calendar Above.<br></span></span></p></p> <span id="OSC_h4_8"><span id="OSC_h4_8"></span></span><span style="font-size: 18px;"><span style="font-size: 18px;"> <span style="font-size: 16px;">2. Peek and pop<br></span></span></span> <p><p><span style="font-size: 18px;"><span style="font-size: 16px;">This feature is a new set of user interaction mechanisms, with the following three phases of interaction in Viewcontroller when using 3D touch:<br></span></span></p></p> <p><p><span style="font-size: 18px;"><span style="font-size: 16px;">(1) the user is prompted to interact with the touch, which blurs the interactive controls around</span></span></p></p> <p><p><span style="font-size: 18px;"><span style="font-size: 16px;"></span></span></p></p> <p><p><span style="font-size: 18px;"><span style="font-size: 16px;">(2) continue deep press, The preview view will appear<br></span></span></p></p> <p><p><span style="font-size: 18px;"><span style="font-size: 16px;"></span></span></p></p> <p><p><span style="font-size: 18px;"><span style="font-size: 16px;">(3) further interaction via interactive controls on the view<br></span></span></p></p> <p><p><span style="font-size: 18px;"><span style="font-size: 16px;"></span></span></p></p> <p><p><span style="font-size: 18px;"><span style="font-size: 16px;">This module is designed to interact with the Web Page preview on the URL Connection.</span></span></p></p> <span id="OSC_h4_9"><span id="OSC_h4_9"></span></span><span style="font-size: 18px;"><span style="font-size: 18px;"> <span style="font-size: 16px;">3.Force Properties<br></span></span></span> <p><p><span style="font-size: 16px;">IOS9 provides us with a new interactive parameter: force. We can detect the intensity value of an interaction to do the corresponding interactive processing. For example, we can control the speed of fast forward, the speed of volume increase and so On. </span><br></p></p> <span id="OSC_h3_10"><span id="OSC_h3_10"></span></span><span style="font-size: 16px;"><span style="font-size: 16px;"> <span style="font-size: 18px;">v. Home screen Quick action using the relevant API</span><br></span></span> <p><p><span style="font-size: 18px;"><span style="font-size: 16px;">IOS9 provides us with two kinds of screen labels, static labels and dynamic tags, respectively. </span><br></span></p></p> <span id="OSC_h4_11"><span id="OSC_h4_11"></span></span><span style="font-size: 18px;"><span style="font-size: 18px;"> <span style="font-size: 16px;">1. Static label<br></span></span></span> <p><p><span style="font-size: 18px;"><span style="font-size: 16px;">A static label is a label that we configure in the configuration plist file of the project, which is available after the user installs the program, and the sort is preceded by a dynamic label.<br></span></span></p></p> <p><p><span style="font-size: 18px;"><span style="font-size: 16px;">Let's look at the configuration of the static tag first:</span></span></p></p> <p><p><span style="font-size: 18px;"><span style="font-size: 16px;">First of all, Add the following key value in the Info.plist file (when I was testing, the system did not prompt, can only hand up):</span></span></p></p> <p><p><span style="font-size: 18px;"><span style="font-size: 16px;"></span></span></p></p> <p><p><span style="font-size: 18px;"><span style="font-size: 16px;">An array of Uiapplicationshortcutitems is added first, and the elements added in this array are the corresponding static tags, and in each tag we need to add some key values for the Setting:</span></span></p></p> <p><p><span style="font-size: 18px;"><span style="font-size: 16px;">Required (the following two key values must be set):<br></span></span></p></p> <p><p><span style="font-size: 13.3900003433228px; color: rgb(102, 102, 102); font-family: Courier, Consolas, monospace; widows: 1; background-color: rgb(255, 255, 255);">Uiapplicationshortcutitemtype <span style="font-size: 16px; color: rgb(0, 0, 0); font-family: 微软雅黑, ‘Microsoft YaHei‘; widows: 1; background-color: rgb(255, 255, 255); line-height: 22.5px;">This key value to set a shortcut channel type string</span></span></p></p> <p><p><span style="font-size: 13.3900003433228px; color: rgb(102, 102, 102); font-family: Courier, Consolas, monospace; widows: 1; background-color: rgb(255, 255, 255);">Uiapplicationshortcutitemtitle <span style="font-size: 16px; color: rgb(0, 0, 0); font-family: 微软雅黑, ‘Microsoft YaHei‘; widows: 1; background-color: rgb(255, 255, 255);">The title of this key value setting label</span></span></p></p> <p><p><span style="font-family: 微软雅黑, ‘Microsoft YaHei‘; font-size: 16px;"><span style="font-family: 微软雅黑, ‘Microsoft YaHei‘; color: rgb(0, 0, 0); widows: 1; background-color: rgb(255, 255, 255);">Optional (these key values are not required)</span> <span style="font-family: 微软雅黑, ‘Microsoft YaHei‘; color: rgb(0, 0, 0); widows: 1; background-color: rgb(255, 255, 255);">:</span></span></p></p> <p><p><span style="font-size: 13.3900003433228px; color: rgb(102, 102, 102); font-family: Courier, Consolas, monospace; widows: 1; background-color: rgb(255, 255, 255);">Uiapplicationshortcutitemsubtitle <span style="font-size: 16px; color: rgb(0, 0, 0); font-family: Courier, Consolas, monospace; widows: 1; background-color: rgb(255, 255, 255);">Setting the subtitle of a label</span></span></p></p> <p><p><span style="font-size: 13.3900003433228px; color: rgb(102, 102, 102); font-family: Courier, Consolas, monospace; widows: 1; background-color: rgb(255, 255, 255);">Uiapplicationshortcutitemicontype <span style="font-size: 16px; color: rgb(0, 0, 0); font-family: Courier, Consolas, monospace; widows: 1; background-color: rgb(255, 255, 255);">setting label icon type</span></span></p></p> <p><p><span style="font-size: 13.3900003433228px; color: rgb(102, 102, 102); font-family: Courier, Consolas, monospace; widows: 1; background-color: rgb(255, 255, 255);">Uiapplicationshortcutitemiconfile <span style="font-size: 16px; color: rgb(0, 0, 0); font-family: Courier, Consolas, monospace; widows: 1; background-color: rgb(255, 255, 255);">icon file for the Settings tab</span></span></p></p> <p><p><span style="font-size: 13.3900003433228px; color: rgb(102, 102, 102); font-family: Courier, Consolas, monospace; widows: 1; background-color: rgb(255, 255, 255);">Uiapplicationshortcutitemuserinfo <span style="font-size: 16px; color: rgb(0, 0, 0); font-family: Courier, Consolas, monospace; widows: 1; background-color: rgb(255, 255, 255);">Setting Information dictionary (for value Transfer)</span></span></p></p> <p><p><span style="font-size: 13.3900003433228px; color: rgb(102, 102, 102); font-family: Courier, Consolas, monospace; widows: 1; background-color: rgb(255, 255, 255);"><span style="font-size: 16px; color: rgb(0, 0, 0); font-family: Courier, Consolas, monospace; widows: 1; background-color: rgb(255, 255, 255);">After we have set up, run the program, with our previous method to test, the effect is as Follows:</span></span></p></p> <p><p><span style="font-size: 13.3900003433228px; color: rgb(102, 102, 102); font-family: Courier, Consolas, monospace; widows: 1; background-color: rgb(255, 255, 255);"><span style="font-size: 16px; color: rgb(0, 0, 0); font-family: Courier, Consolas, monospace; widows: 1; background-color: rgb(255, 255, 255);"></span></span></p></p> <span id="OSC_h4_12"><span id="OSC_h4_12"></span></span>2. Dynamic Label<br> <p><p><span style="font-size: 16px;">Dynamic tagging is a class that we add to our program by code, with three main categories:</span><br></p></p> <p><p><span style="font-size: 16px;">Uiapplicationshortcutitem <span style="font-size: 16px; color: rgb(0, 0, 0);">Creating a 3DTouch tag class</span></span></p></p> <p><p>Uimutableapplicationshortcutitem <span style="color: rgb(0, 0, 0); font-size: 16px;">Creating a Variable 3DTouch Label class</span></p></p> <p><p>Uiapplicationshortcuticon <span style="font-size: 16px; color: rgb(0, 0, 0);">Create a class for a picture icon in a label</span></p></p> <p><p> <span style="font-size:16px; color:rgb (0, 0, 0);"> Because these classes are the newly added classes in iOS9, their APIs are not very complex, so let's take a brief explanation of the methods and Properties: <br> </span> </p></p> <pre class="brush:cpp;toolbar: true; auto-links: false;">@interface uiapplicationshortcutitem : nsobject <nscopying, nsmutablecopying>// Here are the two initialization methods create a label by setting Type,title properties, here the icon is Uiapplicationshortcuticon object, we will say- (instancetype) Initwithtype: (nsstring *) type localizedtitle: (nsstring *) localizedtitle localizedsubtitle :(nullable nsstring *) localizedsubtitle icon: (nullable uiapplicationshortcuticon *) Icon userinfo: (nullable nsdictionary *) userinfo ns_designated_initializer;- ( Instancetype) initwithtype: (nsstring *) type localizedtitle: (nsstring *) localizedTitle;// Here are some read-only properties that get the corresponding property values @property (nonatomic, copy, readonly) NSString *type; @property (nonatomic, copy, readonly) NSString *localizedTitle; @property (nullable, Nonatomic, copy, readonly) NSString *localizedSubtitle; @property (nullable, Nonatomic, copy, readonly) uiapplicationshortcuticon *icon; @property (nullable, nonatomic, copy, readonly) nsdictionary<nsstring *, id <nssecurecoding>> *userinfo;</pre> <pre class="brush:cpp;toolbar: true; auto-links: false;"></pre> <pre class="brush:cpp;toolbar: true; auto-links: false;"><pre class="brush:cpp;toolbar: true; auto-links: false;">This class creates a icon@interface uiapplicationshortcuticon:nsobject <nscopying>//in the tag to create a system-style icon+ (instancetype) Iconwithtype: (uiapplicationshortcuticontype) type;//create A custom picture icon+ (instancetype) iconwithtemplateimagename: ( NSString *) templateimagename; @end</pre></pre> <p><p><span style="font-size: 16px;">Once you have created the tag, add it as a hortcutitems array of application, as shown in the following example:</span><br></p></p> <pre class="brush:cpp;toolbar: true; auto-links: false;"><pre class="brush:cpp;toolbar: true; auto-links: false;">-(void) viewdidload {[super viewdidload]; Additional setup after loading the view, typically from a nib. Create Uiapplicationshortcutitem * item = [[uiapplicationshortcutitem alloc]initwithtype:@ "two" localizedtitle:@ "second label" localizedsubtitle:@ "see me," Icon:[uiapplicationshortcuticon iconwithtype:uiapplicationshortcuticontypeplay] userInfo : nil]; Add [uiapplication Sharedapplication].shortcutitems = @[item];}</pre></pre> <p><p><span style="font-size: 16px;">The effect is as Follows:</span><br></p></p> <p><p><span style="font-size: 16px;"></span></p></p> <p><p><span style="font-size: 16px;">here, the enumeration of system style icons is listed Below:<br></span></p></p> <pre class="brush:cpp;toolbar: true; auto-links: false;"><pre class="brush:cpp;toolbar: true; auto-links: false;">typedef ns_enum (nsinteger, Uiapplicationshortcuticontype) {uiapplicationshortcuticontypecompose,//edit icon UIApplicat Ionshortcuticontypeplay,//play icon uiapplicationshortcuticontypepause,//pause icon uiapplicationshortcuticontypeadd,//add icon Uiapplicationshortcuticontypelocation,//position icon Uiapplicationshortcuticontypesearch,//search icon Uiapplicationshortcuticontypeshare//share icon} Ns_enum_available_ios (9_0);</pre></pre> <p><p><span style="font-size: 16px;">Some notes:</span><br></p></p> <p><p><span style="font-size: 16px;">1, the shortcut tag can create up to four, including static and Dynamic.</span></p></p> <p><p><span style="font-size: 16px;">2, the title of each label and icon at most two lines, the more will be used ... Omitted</span></p></p> <span id="OSC_h3_13"><span id="OSC_h3_13"></span></span><span style="font-size: 16px;"><span style="font-size: 16px;"><span style="font-size: 18px;">Vi. Conclusion</span><br></span></span> <p><p><span style="font-size: 18px;"><span style="font-size: 16px;">About 3DTouch in UIView preview function and the application of the new force attribute in the uitouch, because not good presentation, here is no longer summarized, you can use the corresponding class and attributes in the header file to understand them, and finally, if there are omissions and errors, please Correct.</span><br></span></p></p> <p><p><span style="font-size: 18px;"><span style="font-size: 16px;"><br></span></span></p></p> <p><p><span style="font-size: 24px; color: rgb(0, 176, 240);">Welcome reprint please indicate the source</span></p></p><p><p>IOS9 series feature One--3d Touch</p></p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service