Skip to content

Hyman00/YJ3DTouch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YJ3DTouch

YJ3DTouch can easily implement 3D Touch.

How to use

First

pod 'YJ3DTouch', '~> 1.0'
#import "UIViewController+YJ3DTouch.h"

Active 3D Touch for UITableView

[self yj_active3DTouchTable:self.tableView forNavigation:self.navigationController];

1, The method will automatic register 3D Touch for each cell.

2, The table of delegate need implement the "tableView: didSelectRowAtIndexPath:" method.

Active 3D Touch for UICollectionView

[self yj_active3DTouchCollectionView:self.collectionView forNavigation:self.navigationController];

1, The method will automatic register 3D Touch for each cell.

2, The collectionView of delegate need implement the "collectionView: didSelectItemAtIndexPath:" method.

3, If the collectionView: shouldSelectItemAtIndexPath: method for the UICollectionViewDelegate return NO, at the indexPath of cell will not be registered 3D Touch.

Active 3D Touch for UIView

[self yj_active3DTouchView:self.pushButton
               clickTarget:self
               clickAction:@selector(pushButtonTap)
                  argument:nil
             forNavigation:self.navigationController];

1, If the view is UITableView or UICollectionView, the method will ignore target, action, argument.

2, You can also use the method to active 3D Touch for UITableViewCell or UICollectionViewCell. However, you can no longer use the "yj_active3DTouchTable:forNavigation:" or "yj_active3DTouchCollectionView:forNavigation:" method.

Active 3D Touch with action

YJ3DTouchConfig *actionItemConfig = [YJ3DTouchConfig new];
actionItemConfig.navigation = self.navigationController;
actionItemConfig.clickActionTarget = self;
actionItemConfig.clickAction = @selector(actionItemsBtnTap);
    
UIPreviewAction *action1 = [UIPreviewAction actionWithTitle:@"action1"
                                                      style:UIPreviewActionStyleDefault
                                                    handler:^(UIPreviewAction * _Nonnull action, UIViewController * _Nonnull previewViewController) {
                                                            NSLog(@"action1");
                                                    }];
UIPreviewAction *action2 = [UIPreviewAction actionWithTitle:@"action2"
                                                      style:UIPreviewActionStyleDefault
                                                    handler:^(UIPreviewAction * _Nonnull action, UIViewController * _Nonnull previewViewController) {
                                                            NSLog(@"action2");
                                                    }];
actionItemConfig.previewActionItems = @[action1, action2];
[self yj_active3DTouchView:self.actionItemsBtn touchConfig:actionItemConfig];