|
11 | 11 |
|
12 | 12 | ``` |
13 | 13 | #pragma mark - dataSource |
14 | | -- (NSInteger)cardViewPageCountForView:(MYCardView *)cardView |
| 14 | +- (NSInteger)handleViewPageCountForView:(MYCardView *)handleView |
15 | 15 | { |
16 | 16 | return self.dataSource.count; |
17 | 17 | } |
18 | 18 |
|
19 | | -- (CGSize)cardViewSizeForItem:(MYCardView *)cardView |
| 19 | +- (CGSize)handleViewSizeForItem:(MYCardView *)handleView |
20 | 20 | { |
21 | 21 | return CGSizeMake(345,480); |
22 | 22 | } |
23 | 23 |
|
24 | | -- (CGFloat)cardViewTopInsetForItem:(MYCardView *)cardView |
| 24 | +- (CGFloat)handleViewTopInsetForItem:(MYCardView *)handleView |
25 | 25 | { |
26 | | -return 10; |
| 26 | +return 12; |
27 | 27 | } |
28 | 28 |
|
29 | | -- (MYCardViewItem *)cardView:(MYCardView *)cardView itemForIndex:(NSInteger)index |
| 29 | +- (__kindof MYCardViewItem *)handleView:(MYCardView *)handleView itemForIndex:(NSInteger)index |
30 | 30 | { |
| 31 | +if (index>self.dataSource.count-1) { |
| 32 | +return nil; |
| 33 | +} |
31 | 34 | //TestCardItem类继承于MYCardViewItem |
32 | | -TestCardItem *cardItem = [cardView dequeueReusableItemWithIdentifier:@"TestCardItem"]; |
| 35 | +TestCardItem *cardItem = [handleView dequeueReusableItemWithIdentifier:@"TestCardItem"]; |
33 | 36 | cardItem.carModel = self.dataSource[index]; |
34 | 37 | return cardItem; |
35 | 38 | } |
36 | 39 |
|
| 40 | +
|
| 41 | +
|
37 | 42 | #pragma mark - delegate |
38 | | -- (void)cardView:(MYCardView *)cardView didClickItemAtIndex:(NSInteger)index |
| 43 | +- (void)handleView:(MYCardView *)handleView didClickItemAtIndex:(NSInteger)index |
39 | 44 | { |
40 | 45 | NSLog(@"==============点击了卡片===========索引%li",index); |
41 | 46 | } |
42 | 47 |
|
43 | | -- (void)cardView:(MYCardView *)cardView cardDidSCroll:(NSInteger)index dragMode:(MYCardViewDragMode)dragMode |
| 48 | +- (void)handleView:(MYCardView *)handleView beginMoveDirection:(MYCardViewDragDirectionType)direction itemIndex:(NSInteger)index dragMode:(MYCardViewDragMode)dragMode |
44 | 49 | { |
45 | | -NSLog(@"==============卡片正在滑动==========索引%li",index); |
| 50 | +NSLog(@"--------开始滑动--------"); |
46 | 51 | } |
47 | 52 |
|
48 | | -- (void)cardView:(MYCardView *)cardView cardEndScroll:(NSInteger)index dragMode:(MYCardViewDragMode)dragMode |
| 53 | +- (void)handleView:(MYCardView *)handleView cardEndScroll:(MYCardViewDragDirectionType)direction itemIndex:(NSInteger)index dragMode:(MYCardViewDragMode)dragMode |
49 | 54 | { |
50 | | -NSLog(@"==============卡片结束滑动==========索引%li",index); |
| 55 | +NSLog(@"--------滑动结束--------"); |
51 | 56 | } |
52 | 57 |
|
53 | | -- (void)cardView:(MYCardView *)cardView cancelDrag:(MYCardViewDragDirectionType)direction itemIndex:(NSInteger)index dragMode:(MYCardViewDragMode)dragMode |
| 58 | +- (void)handleView:(MYCardView *)handleView cardDidScroll:(MYCardViewDragDirectionType)direction itemIndex:(NSInteger)index dragMode:(MYCardViewDragMode)dragMode |
54 | 59 | { |
55 | | -NSLog(@"============取消了卡片滑动============索引%li",index); |
| 60 | +NSLog(@"-------正在滑动----------"); |
56 | 61 | } |
57 | 62 |
|
58 | | -- (void)cardView:(MYCardView *)cardView effectiveDragDirection:(MYCardViewDragDirectionType)direction itemIndex:(NSInteger)index dragMode:(MYCardViewDragMode)dragMode |
| 63 | +- (void)handleView:(MYCardView *)handleView cancelDrag:(MYCardViewDragDirectionType)direction itemIndex:(NSInteger)index dragMode:(MYCardViewDragMode)dragMode |
| 64 | +{ |
| 65 | +NSLog(@"------取消了第%li个的滑动",index); |
| 66 | +} |
| 67 | +
|
| 68 | +- (void)handleView:(MYCardView *)handleView effectiveDragDirection:(MYCardViewDragDirectionType)direction itemIndex:(NSInteger)index dragMode:(MYCardViewDragMode)dragMode |
59 | 69 | { |
60 | 70 | NSLog(@"===========成功滑动卡片==========索引%li",index); |
61 | 71 | } |
62 | 72 |
|
| 73 | +
|
63 | 74 | // 设置代理和数据源 |
64 | 75 | _cardView.dataSource = self; |
65 | 76 | _cardView.delegate = self; |
|
0 commit comments