Skip to content

Instantly share code, notes, and snippets.

@nolili
Created September 26, 2015 06:53
Show Gist options
  • Save nolili/1a17ddcbca68fba33f39 to your computer and use it in GitHub Desktop.
Save nolili/1a17ddcbca68fba33f39 to your computer and use it in GitHub Desktop.
3D touch Example
#import "ViewController.h"
@interface ViewController () <UIViewControllerPreviewingDelegate>
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self registerForPreviewingWithDelegate:self sourceView:self.view];
}
#pragma mark - UIViewControllerPreviewingDelegate
- (nullable UIViewController *)previewingContext:(id <UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location{
UIViewController *viewController = [[UIViewController alloc] init];
viewController.view.backgroundColor = [UIColor redColor];
return viewController;
}
- (void)previewingContext:(id <UIViewControllerPreviewing>)previewingContext commitViewController:(UIViewController *)viewControllerToCommit
{
[self presentViewController:viewControllerToCommit animated:YES completion:nil];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment