Search code examples
iosobjective-c3dtouch

How to hard press button in iPhone and detact 3D touch?


I have on Unbutton and i want to open detail page on hard press on it.

so how it possible let me know.


Solution

  • #pragma mark - Previewing delegate
    - (UIViewController *)previewingContext:(id <UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location
    {
        UIViewController *detailVC = [self.storyboard instantiateViewControllerWithIdentifier:@"detail"];
        detailVC.preferredContentSize = CGSizeMake(0.0, 568.0);
        previewingContext.sourceRect = self.btnDetail.frame;
        return detailVC;
    }
    
    - (void)previewingContext:(id <UIViewControllerPreviewing>)previewingContext commitViewController:(UIViewController *)viewControllerToCommit{
        [self showViewController:viewControllerToCommit sender:self];
    }