Detect touch on UIWebView but ignore swipe or touch on interactive elements (link or onclick)
Date : March 29 2020, 07:55 AM
|
With 3D touch peek and pop, how do you detect the user panning during a peek (like Facebook)?
Tag : ios , By : chintown
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , There's a little trick where you can track the user's touch location while Peeking. You basically have a gesture recognizer that begins tracking the user's touch location when you start Peeking and ends tracking once the user Pops the view controller or releases his/her touch. The gesture recognizer should be added to the view of the view controller that is bringing up the Peek. @property (nonatomic, weak, nullable) ViewControllerClass *peekedVC;
- (void)handleGestureRecognizer:(UIPanGestureRecognizer *)gr {
if (peekedVC && gr.state == UIGestureRecognizerStateChanged) {
CGPoint point = [gr locationInView:self.view];
[peekedVC handle:point.x];
}
}
- (UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)previewingContext
viewControllerForLocation:(CGPoint)location {
NSIndexPath *indexPath = [self.collectionView indexPathForItemAtPoint:location];
UICollectionViewCell *cell = [self.collectionView cellForItemAtIndexPath:indexPath];
[previewContext setSourceRect:cell.frame];
ViewControllerClass *vc = [ViewControllerClass new];
self.peekedVC = vc;
return vc;
}
- (void)previewingContext:(id<UIViewControllerPreviewing>)previewingContext
commitViewController:(UIViewController *)viewControllerToCommit {
self.peekedVC = nil;
[self showViewController:viewControllerToCommit sender:self];
}
|
3D Touch Peek with Top Bar
Date : March 29 2020, 07:55 AM
wish help you to fix your issue In previewingContext(_:, viewControllerForLocation:), wrap your view controller in a UINavigationController and return that.
|
3D Touch Peek And Pop on UITableViewCell Objective C Code. (Force Touch)
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Peek And Pop Effect on a TableViewCell and Collection View Cell With Actions 1)You should address your caller viewController class as UIViewControllerPreviewing Delegate @property (nonatomic, strong) id previewingContext;
- (void)viewDidLoad {
[super viewDidLoad];
[self forceTochIntialize];
}
-(void)forceTouchIntialize{
if ([self isForceTouchAvailable]) {
self.previewingContext = [self registerForPreviewingWithDelegate:self sourceView:self.view];
}
}
- (BOOL)isForceTouchAvailable {
BOOL isForceTouchAvailable = NO;
if ([self.traitCollection respondsToSelector:@selector(forceTouchCapability)]) {
isForceTouchAvailable = self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable;
}
return isForceTouchAvailable;
}
- (UIViewController *)previewingContext:(id<UIViewControllerPreviewing> )previewingContext viewControllerForLocation:(CGPoint)location{
CGPoint cellPostion = [yourTableView convertPoint:location fromView:self.view];
NSIndexPath *path = yourTableView indexPathForRowAtPoint:cellPostion];
if (path) {
UITableViewCell *tableCell = [yourTableView
cellForRowAtIndexPath:path];
//Pushing to a nib File
PushViewController *previewController = [[PushViewController alloc] initWithNibName:@"PushViewController" bundle:nil];
//To Pass data to Preview ViewController
// id temp = [yourDataArray objectAtIndex:path.row];
// PushViewController.anyObject=temp;
previewingContext.sourceRect = [self.view convertRect:tableCell.frame fromView: yourTableView
]; return previewController;
}
return nil;
}
-(void)previewingContext:(id )previewingContext commitViewController: (UIViewController *)viewControllerToCommit {
[self.navigationController showViewController:viewControllerToCommit sender:nil];
}
- (NSArray<id> *)previewActionItems {
UIPreviewAction *previewAction1 = [UIPreviewAction actionWithTitle:@"delete" style:UIPreviewActionStyleDefault handler:^(UIPreviewAction *action, UIViewController *previewViewController){
}];
UIPreviewAction *previewAction2 = [UIPreviewAction actionWithTitle:@"archive" style:UIPreviewActionStyleDefault handler:^(UIPreviewAction *action, UIViewController *previewViewController){
}];
return @[previewAction1,previewAction2];
}
|
Is it possible to add 3D-touch without peek?
Tag : ios , By : Andrew Bailey
Date : March 29 2020, 07:55 AM
it helps some times So it turns out that 3D-touch (or force-touch or whatever it's called) isn't only available through the implementation of UIViewControllerPreviewingDelegate. This delegate's job is to decide what to present with peek/pop, while the core function of peek and pop can be accessed through a normal UIGestureRecognizer. I followed this guide to create my own ForceGestureRecognizer, but decided to subclass UILongPressGestureRecognizer instead of UIGestureRecognizer (to combine it with existing functions). That guide, along with this (to create the little shake feedback using UINotificationFeedbackGenerator), and together with some CGAffineTransform-changes based on the force of the touch really made it perfect.
|