Pages

Tuesday, July 11, 2017

How To Add 3D Touch For Your IOS App


3D Feel Utility

The 3D Touch technology was introduced on the i phone 6s and 6s+. Devices supporting 3D Touch have a tap force hypersensitive display, measuring the pressure around the screen. The 3D Touch engineering allows users to media an app icon around the Home screen and get yourself a quick access to some functionality presented inside the app. Also, within a great app, a user can access some features.

From iOS 9, The apple company made 3D Touch APIs accessible:

Home Screen Quick Actions API
UIKit peek and also pop API
Web see peek and pop API
UITouch push properties

In order to learn whether a device helps the 3D Touch engineering, you have to examine out the forceTouchCapability beliefs. While the app will be working, a user are able to turn off 3D Touch, so this value must be checked in the traitCollectionDidChange assign method.

- (void)traitCollectionDidChange: (UITraitCollection *)previousTraitCollection

if (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)

NSLog(@"3D Touch is available");

 else

NSLog(@"3D Touch is not available on this device");

animations Touch Quick Actions
You can find two types of Residence Screen Quick Actions: energetic and static.

Static actions are defined inside the Info. plist file inside UIApplicationShortcutItems array.

Dynamic actions must be added to the UIApplication application object inside the shortcutItems property. You are able to use two methods for generation:

Method 1

init(type: Stringed,

localizedTitle: String,

localizedSubtitle: Stringed?,

icon: UIApplicationShortcutIcon?,

userInfo: [AnyHashable: Any]? = nil)

This technique creates a Home display screen dynamic quick action using a header, optional subheader, recommended icon, and optional consumer info dictionary.

Method a couple of

convenience init(type: String,

localizedTitle: String)

Creates a property screen dynamic quick action using a header but with simply no icon.

Quick Actions Handler
func application(application: UIApplication,

performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: Bool -> Void)

let didHandle: Bool = /* handle the quick action using shortcutItem */

completionHandler(didHandle)

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]? ) -> Bool

var performAdditionalHandling = true

if let shortcutItem = launchOptions?[UIApplicationLaunchOptionsShortcutItemKey]

as? UIApplicationShortcutItem

/* handle the quick action using shortcutItem */

performAdditionalHandling = false

return performAdditionalHandling

UIKit glimpse and pop API
This API is employed for content preview (quick) and further transition to it. New methods in UIViewController regarding ViewController registration and sign up cancellation allow notifications as to whether it's going to be used by animations Touch. Additionally added are usually new protocols for animations Touch support.

ViewController sign up:
-(id)registerForPreviewingWithDelegate: (id)delegate sourceView: (UIView *)sourceView;

Glimpse:

- (UIViewController *)previewingContext: (id)previewingContext viewControllerForLocation: (CGPoint)location

// check if we're not already displaying a preview controller

if ([self.presentedViewController isKindOfClass:[PreviewViewController class]])

return nil;

// shallow press: return the preview controller here (peek)

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

UIViewController *previewController = [storyboard instantiateViewControllerWithIdentifier:@"PreviewView"];

return previewController;

Devote:

- (void)previewingContext: (id)previewingContext commitViewController: (UIViewController *)viewControllerToCommit

// deep press: bring up the commit view controller (pop)

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

UIViewController *commitController = [storyboard instantiateViewControllerWithIdentifier:@"CommitView"];

[self showViewController:commitController sender:self];

// alternatively, use the view controller that's being provided here (viewControllerToCommit)

Inside preview, you can furthermore add UIPreviewAction and UIPreviewActionGroup

UIPreviewAction *action1 = [UIPreviewAction actionWithTitle:@"Action 1"

style:UIPreviewActionStyleDefault handler:^(UIPreviewAction * _Nonnull action,

UIViewController * _Nonnull previewViewController)

NSLog(@"Action 1 triggered");

];

// add these to an arrary

NSArray *actions = @[action1, action2, action3];

// add all actions with a group

UIPreviewActionGroup *group1 = [UIPreviewActionGroup actionGroupWithTitle:@"Action Group"

style:UIPreviewActionStyleDefault actions:actions];

NSArray *group = @[group1];

The actual Potential of 3D Feel

As developers are learning the benefits of the particular 3D technology, it becomes clear which it will become a staple.

Hence, this contribution to unlocking the actual potential of 3D Feel development in Shakuro.

We are looking towards exploring this productive feature further to produce applications more usable, quickly, and robust. In-app usage of the technology has every one of the chances to tackle just how swiping has ingrown directly into our daily device use.

Techsourcenetwork

No comments:

Post a Comment