31 January, 2017

IOS: How to enable ForceTouch support (2/2)

This is part 2 of a double post (see http://blog.clauskonrad.net/2017/01/ios-how-to-enable-force-touch-support-12.html for part 1)

Continuing from the previous post; once you have the UI defined - we need to be able to handle that the app is launched by pressing one of thUIApplicationShortcutItems instead of conventional icon click. The key to detecting this in the app is the appDelegate class (the startup class). As you might remember from part 1, we gave the shortcutItems a unique type (a unique string). These strings are used to identify to the app what shortcut item has been pressed.

As seen from the below image - the first thing when the app is launched is to check the launchOptions  argument. If it is possible to cast that as a UIApplicationShortcutItem - we have been launched from such UISchortcutItem.

The next thing is to determine which item (item1 or item 2) has been used to launch the app.

In my sample app - the startup viewcontroller as seen below is a TabbarController that normally would start the left hand child viewcontroller (Network Info) as this has index = 0 (default). Therefore I can just set the selectedIndex on the tabbarController as seen in the code above. This will allow me to either select the Network Info or Cell Info tab. All from the UIShortcutItem.



I like this post,And I guess that they having fun to read this post,they shall take a good site to make a information,thanks for sharing it to me. TutuApp Android

CNG said...

Your blog provided us with valuable information to work with. Each & every tips of your post are awesome. Thanks a lot for sharing. Keep blogging, Cydia Download iOS 11.3

iPhone/XCode - not all cases are equal!

This bit me! Having made some changes to an iPhone application (Obj-C); everything worked fine in the simulator. But, when deploying the s...