UIViewController+BBA3DTouch.h
5.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//
// UIViewController+BBA3DTouch.h
// BBA3DTouch
//
// Created by hyman on 2017/3/31.
// Copyright © 2017年 hyman. All rights reserved.
//
// MIT License
//
// Copyright (c) 2017 hyman (https://github.com/Hyman00/BBA3DTouch)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#import <UIKit/UIKit.h>
#import "BBA3DTouchConfig.h"
typedef NS_ENUM(NSUInteger, BBA3DViewControllerAppear) {
BBA3DViewControllerAppear_None = 0,
BBA3DViewControllerAppear_WillAppear,
BBA3DViewControllerAppear_DidAppear,
BBA3DViewControllerAppear_WillDisappear,
BBA3DViewControllerAppear_DidDisappear
};
typedef NS_ENUM(NSUInteger, BBA3DTouchStatus) {
BBA3DTouchStatus_None = 0,
BBA3DTouchStatus_Prepared,
BBA3DTouchStatus_Previewing,
BBA3DTouchStatus_Poped
};
typedef NS_ENUM(NSUInteger, BBA3DTouchActionStatus) {
BBA3DTouchActionStatus_None = 0,
BBA3DTouchActionStatus_WillPeek,
BBA3DTouchActionStatus_DidPeek,
BBA3DTouchActionStatus_WillPop,
BBA3DTouchActionStatus_DidPop,
BBA3DTouchActionStatus_Cancel
};
/**
* @brief 当用户在进行3D Touch相关操作时,将会发送该通知,并传递对应在那个页面进行的操作,以及当前操作的状态。
* 即:userInfo里包括2个key-value:{BBA3DTouchActionUserInfoPageKey: 操作的页面, BBA3DTouchActionUserInfoStatusKey: 当前操作状态}
*/
extern NSString * const BBA3DTouchActionNotification;
extern NSString * const BBA3DTouchActionUserInfoPageKey;
extern NSString * const BBA3DTouchActionUserInfoStatusKey;
/**
* @brief It will be called when the sourceView will peek or pop.
* If the block return NO, then the 3D Touch will lose efficacy.
(It only takes effect when status is BBA3DTouchStatus_WillPeek and BBA3DTouchStatus_WillPop)
*
* @param sourceView A source view, in a previewing view controller’s view hierarchy, responds to a forceful touch by the use
*/
typedef BOOL(^BBA3DTouchTriggerBlock) (BBA3DTouchActionStatus status, UIView *sourceView);
@interface UIViewController (BBA3DTouch) <UIViewControllerPreviewingDelegate>
@property (nonatomic, assign, readonly) BBA3DViewControllerAppear bba_appearStatus;
@property (nonatomic, assign, readonly) BBA3DTouchStatus bba_3DTouchStatus API_AVAILABLE(ios(9.0));
@property (nonatomic, assign, readonly) BBA3DTouchActionStatus bba_3DTouchActionStatus API_AVAILABLE(ios(9.0));
@property (nonatomic, copy, setter=bba_set3DTouchTriggerBlock:) BBA3DTouchTriggerBlock bba_3DTouchTriggerBlock API_AVAILABLE(ios(9.0));
/**
* @brief active 3D Touch for UITableView
*
* The method will automatic register 3D Touch for each cell.
*
* @note
* Need to implement the tableView: didSelectRowAtIndexPath: method for the UITableViewDelegate
*
*/
- (void)bba_active3DTouchTable:(UITableView *)tableView
forNavigation:(UINavigationController *)navigation API_AVAILABLE(ios(9.0));
/**
* @brief active 3D Touch for UICollectionView
*
* The method will automatic register 3D Touch for each cell.
*
* @note
* 1, Need to implement the collectionView: didSelectItemAtIndexPath: for the UICollectionViewDelegate
*
* 2, If the collectionView: shouldSelectItemAtIndexPath: method for the UICollectionViewDelegate return NO, at the indexPath of cell will not be registered 3D Touch;
*
*/
- (void)bba_active3DTouchCollectionView:(UICollectionView *)collectionView
forNavigation:(UINavigationController *)navigation API_AVAILABLE(ios(9.0));
/**
* @brief active 3D Touch for view
*
* @param target the responder of the click
* @param action the action of the click
* @param argument an object that is the sole argument of the action
*
* @note
* If the view is UITableView or UICollectionView, the method will ignore target, action, argument
*/
- (void)bba_active3DTouchView:(UIView *)view
clickTarget:(NSObject *)target
clickAction:(SEL)action
argument:(id)argument
forNavigation:(UINavigationController *)navigation API_AVAILABLE(ios(9.0));
- (void)bba_active3DTouchView:(UIView *)view touchConfig:(BBA3DTouchConfig *)touchConfig API_AVAILABLE(ios(9.0));
@end