3D Contact Application
The 3-d touch era turned into first introduced at the iphone 6s and 6s+. gadgets supporting 3D contact are geared up with a tap pressure touchy show, measuring the pressure at the screen. the 3D contact generation lets in users to press an app icon on the home display screen and get a quick get right of entry to to a few functionality provided within the app. additionally, inside an app, a user can get get entry to to some functions.
From ios nine, apple made 3D touch apis available:
- Home display quick movement api
- Uikit peek and dad api
- Net view peek and pa api
- Uitouch force properties
A good way to find out whether or not a tool helps the three-D touch era, you need to study out the forcetouchcapability values. even as the app is running, a person can turn off three-D contact, so this price needs to be checked in the traitcollectiondidchange delegate technique.
- (void)traitcollectiondidchange:(uitraitcollection *)previoustraitcollection
if (self.traitcollection.forcetouchcapability == uiforcetouchcapabilityavailable)
nslog(@"3-D contact is to be had");
else
nslog(@"3-d contact isn't always to be had on this device");
3D Touch Quick Actions
There are two forms of home display short actions: dynamic and static.
Static movements are defined within the info.plist file within the uiapplicationshortcutitems array.
Dynamic moves should be delivered to the uiapplication software item inside the shortcutitems assets. you could use techniques for introduction:
method 1
init(kind: string,
localizedtitle: string,
localizedsubtitle: string?,
icon: uiapplicationshortcuticon?,
userinfo: [AnyHashable: Any]? = nil)
this technique creates a domestic display dynamic brief motion with a header, non-compulsory subheader, elective icon, and optional person data dictionary.
technique 2
comfort init(type: string,
localizedtitle: string)
creates a home screen dynamic quick motion with a header however with no icon.
short actions handler
func application(application: uiapplication,
performactionforshortcutitem shortcutitem: uiapplicationshortcutitem, completionhandler: bool -> void)
permit didhandle: bool = /* cope with the quick action using shortcutitem */
completionhandler(didhandle)
func application(software: uiapplication,didfinishlaunchingwithoptions launchoptions: [NSObject: AnyObject]?) -> bool
var performadditionalhandling = actual
if permit shortcutitem = launchoptions?[UIApplicationLaunchOptionsShortcutItemKey]
as? uiapplicationshortcutitem
/* take care of the fast action the use of shortcutitem */
performadditionalhandling = fake
return performadditionalhandling
uikit peek and dad api
this api is used for content preview (brief) and further transition to it. new techniques in uiviewcontroller for viewcontroller registration and registration cancellation allow notifications as to whether or not it's far going to be used by 3-d contact. additionally introduced are new protocols for 3-d touch aid.
viewcontroller registration:
-(id)registerforpreviewingwithdelegate:(id)delegate sourceview:(uiview *)sourceview;
peek:
- (uiviewcontroller *)previewingcontext: (identification)previewingcontext viewcontrollerforlocation:(cgpoint)location
// take a look at if we're no longer already showing a preview controller
if ([self.presentedviewcontroller iskindofclass:[PreviewViewController class]])
go back nil;
// shallow press: return the preview controller right here (peek)
uistoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
uiviewcontroller *previewcontroller = [storyboard instantiateViewControllerWithIdentifier:@"PreviewView"];
go back previewcontroller;
commit:
- (void)previewingcontext:(identity)previewingcontext commitviewcontroller:(uiviewcontroller *)viewcontrollertocommit
// deep press: carry up the devote view controller (pop)
uistoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
uiviewcontroller *commitcontroller = [storyboard instantiateViewControllerWithIdentifier:@"CommitView"];
[self showViewController:commitController sender:self];
// as an alternative, use the view controller it really is being furnished right here (viewcontrollertocommit)
in preview, you can additionally add uipreviewaction and uipreviewactiongroup
uipreviewaction *action1 = [UIPreviewAction actionWithTitle:@"Action 1"
style:UIPreviewActionStyleDefault handler:^(UIPreviewAction * _Nonnull action,
UIViewController * _Nonnull previewViewController)
NSLog(@"Action 1 triggered");
];
// upload them to an arrary
nsarray *moves = @[action1, action2, action3];
// upload all actions to a collection
uipreviewactiongroup *group1 = [UIPreviewActionGroup actionGroupWithTitle:@"Action Group"
style:UIPreviewActionStyleDefault actions:actions];
nsarray *institution = @[group1];
the authentic potential of three-D touch
as builders are gaining knowledge of the advantages of the 3-D era, it becomes clean that it becomes a staple.
Therefore, this contribution to unlocking the genuine capacity of three-D touch development in shakuro.
We're looking ahead to exploring this efficient function similarly to make programs greater usable, fast, and sturdy. in-app use of the era has all of the possibilities to address the way swiping has ingrown into our day by day tool usage.
0 Comments