├── .gitignore ├── .swift-version ├── DHDragableCellTableView ├── DHDragableCellTableView.h └── DHDragableCellTableView.m ├── LICENSE ├── README.md └── demo ├── DHDragableCellTableView.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── DHDragableCellTableView ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── DHDragableCellTableView │ ├── DHDragableCellTableView.h │ └── DHDragableCellTableView.m ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── DHDragableCellTableViewTests ├── DHDragableCellTableViewTests.m └── Info.plist └── DHDragableCellTableViewUITests ├── DHDragableCellTableViewUITests.m └── Info.plist /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | # CocoaPods 32 | # 33 | # We recommend against adding the Pods directory to your .gitignore. However 34 | # you should judge for yourself, the pros and cons are mentioned at: 35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 36 | # 37 | # Pods/ 38 | 39 | # Carthage 40 | # 41 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 42 | # Carthage/Checkouts 43 | 44 | Carthage/Build 45 | 46 | # fastlane 47 | # 48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 49 | # screenshots whenever they are needed. 50 | # For more information about the recommended setup visit: 51 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 52 | 53 | fastlane/report.xml 54 | fastlane/Preview.html 55 | fastlane/screenshots 56 | fastlane/test_output 57 | 58 | # Code Injection 59 | # 60 | # After new code Injection tools there's a generated folder /iOSInjectionProject 61 | # https://github.com/johnno1962/injectionforxcode 62 | 63 | iOSInjectionProject/ 64 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 2.3 2 | -------------------------------------------------------------------------------- /DHDragableCellTableView/DHDragableCellTableView.h: -------------------------------------------------------------------------------- 1 | // 2 | // DHDragableCellTableView.h 3 | // DHDragableCellTableView 4 | // 5 | // Created by jiaxin on 16/2/15. 6 | // Copyright © 2016年 jiaxin. All rights reserved. 7 | // 8 | 9 | #import 10 | @class DHDragableCellTableView; 11 | 12 | @protocol DHDragableCellTableViewDataSource 13 | 14 | @required 15 | 16 | /** 17 | 获取tableView的数据源数组 18 | */ 19 | - (NSArray *)dataSourceArrayInTableView:(DHDragableCellTableView *)tableView; 20 | /** 21 | 返回移动之后调换后的数据源 22 | */ 23 | - (void)tableView:(DHDragableCellTableView *)tableView newDataSourceArrayAfterMove:(NSArray *)newDataSourceArray; 24 | 25 | @end 26 | 27 | @protocol DHDragableCellTableViewDelegate 28 | @optional 29 | /** 30 | 将要开始移动indexPath位置的cell 31 | */ 32 | - (void)tableView:(DHDragableCellTableView *)tableView willMoveCellAtIndexPath:(NSIndexPath *)indexPath; 33 | /** 34 | 完成一次从fromIndexPath cell到toIndexPath cell的移动 35 | */ 36 | - (void)tableView:(DHDragableCellTableView *)tableView didMoveCellFromIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath; 37 | /** 38 | 结束移动cell在indexPath 39 | */ 40 | - (void)tableView:(DHDragableCellTableView *)tableView endMoveCellAtIndexPath:(NSIndexPath *)indexPath; 41 | 42 | @end 43 | 44 | @interface DHDragableCellTableView : UITableView 45 | 46 | @property (nonatomic, weak) id dataSource; 47 | @property (nonatomic, weak) id delegate; 48 | /** 49 | 长按手势最小触发时间,默认1.0,最小0.2 50 | */ 51 | @property (nonatomic, assign) CGFloat gestureMinimumPressDuration; 52 | /** 53 | 自定义可移动cell的截图样式 54 | */ 55 | @property (nonatomic, copy) void (^drawMovalbeCellBlock)(UIView *DragableCell); 56 | /** 57 | 是否允许拖动到屏幕边缘后,开启边缘滚动,默认YES 58 | */ 59 | @property (nonatomic, assign) BOOL canEdgeScroll; 60 | /** 61 | 边缘滚动触发范围,默认150,越靠近边缘速度越快 62 | */ 63 | @property (nonatomic, assign) CGFloat edgeScrollRange; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /DHDragableCellTableView/DHDragableCellTableView.m: -------------------------------------------------------------------------------- 1 | // 2 | // DH_DragableCellTableView.m 3 | // DH_DragableCellTableView 4 | // 5 | // Created by jiaxin on 16/2/15. 6 | // Copyright © 2016年 jiaxin. All rights reserved. 7 | // 8 | 9 | #import "DHDragableCellTableView.h" 10 | 11 | static NSTimeInterval kDH_DragableCellAnimationTime = 0.25; 12 | 13 | @interface DHDragableCellTableView () 14 | @property (nonatomic, strong) UILongPressGestureRecognizer *gesture; 15 | @property (nonatomic, strong) NSIndexPath *selectedIndexPath; 16 | @property (nonatomic, strong) UIView *tempView; 17 | @property (nonatomic, strong) NSMutableArray *tempDataSource; 18 | @property (nonatomic, strong) CADisplayLink *edgeScrollTimer; 19 | @property (nonatomic, assign) CGPoint lastPoint; 20 | @property (nonatomic, assign) int toBottom; 21 | @end 22 | 23 | @implementation DHDragableCellTableView 24 | 25 | @dynamic dataSource, delegate; 26 | 27 | - (void)dealloc 28 | { 29 | _drawMovalbeCellBlock = nil; 30 | } 31 | 32 | - (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style 33 | { 34 | self = [super initWithFrame:frame style:style]; 35 | if (self) { 36 | [self dh_initData]; 37 | [self dh_addGesture]; 38 | } 39 | return self; 40 | } 41 | 42 | - (instancetype)initWithCoder:(NSCoder *)aDecoder 43 | { 44 | self = [super initWithCoder:aDecoder]; 45 | if (self) { 46 | [self dh_initData]; 47 | [self dh_addGesture]; 48 | } 49 | return self; 50 | } 51 | 52 | - (void)dh_initData 53 | { 54 | _gestureMinimumPressDuration = 1.0f; 55 | _canEdgeScroll = YES; 56 | _edgeScrollRange = 150.f; 57 | } 58 | 59 | #pragma mark Setter 60 | /** 61 | 设置长按时间 62 | */ 63 | - (void)setGestureMinimumPressDuration:(CGFloat)gestureMinimumPressDuration 64 | { 65 | _gestureMinimumPressDuration = gestureMinimumPressDuration; 66 | _gesture.minimumPressDuration = MAX(0.2, gestureMinimumPressDuration); 67 | } 68 | 69 | #pragma mark Gesture 70 | 71 | /** 72 | 添加手势 73 | */ 74 | - (void)dh_addGesture 75 | { 76 | _gesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(dh_processGesture:)]; 77 | _gesture.minimumPressDuration = _gestureMinimumPressDuration; 78 | [self addGestureRecognizer:_gesture]; 79 | } 80 | 81 | /** 82 | 监听手势状态 83 | */ 84 | - (void)dh_processGesture:(UILongPressGestureRecognizer *)gesture 85 | { 86 | switch (gesture.state) { 87 | case UIGestureRecognizerStateBegan: 88 | { 89 | [self dh_gestureBegan:gesture]; 90 | } 91 | break; 92 | case UIGestureRecognizerStateChanged: 93 | { 94 | if (!_canEdgeScroll) { 95 | [self dh_gestureChanged:gesture]; 96 | } 97 | } 98 | break; 99 | case UIGestureRecognizerStateEnded: 100 | case UIGestureRecognizerStateCancelled: 101 | { 102 | [self dh_gestureEndedOrCancelled:gesture]; 103 | } 104 | break; 105 | default: 106 | break; 107 | } 108 | } 109 | 110 | /** 111 | 开始移动 112 | */ 113 | - (void)dh_gestureBegan:(UILongPressGestureRecognizer *)gesture 114 | { 115 | CGPoint point = [gesture locationInView:gesture.view]; 116 | self.lastPoint = point; 117 | NSIndexPath *selectedIndexPath = [self indexPathForRowAtPoint:point]; 118 | if (!selectedIndexPath) { 119 | return; 120 | } 121 | if (self.delegate && [self.delegate respondsToSelector:@selector(tableView:willMoveCellAtIndexPath:)]) { 122 | [self.delegate tableView:self willMoveCellAtIndexPath:selectedIndexPath]; 123 | } 124 | if (_canEdgeScroll) { 125 | //开启边缘滚动 126 | [self dh_startEdgeScroll]; 127 | } 128 | //每次移动开始获取一次数据源 129 | if (self.dataSource && [self.dataSource respondsToSelector:@selector(dataSourceArrayInTableView:)]) { 130 | _tempDataSource = [self.dataSource dataSourceArrayInTableView:self].mutableCopy; 131 | } 132 | _selectedIndexPath = selectedIndexPath; 133 | UITableViewCell *cell = [self cellForRowAtIndexPath:selectedIndexPath]; 134 | _tempView = [self dh_snapshotViewWithInputView:cell]; 135 | if (_drawMovalbeCellBlock) { 136 | //将_tempView通过block让使用者自定义 137 | _drawMovalbeCellBlock(_tempView); 138 | }else { 139 | //配置默认样式 140 | _tempView.layer.shadowColor = [UIColor grayColor].CGColor; 141 | _tempView.layer.masksToBounds = NO; 142 | _tempView.layer.cornerRadius = 0; 143 | _tempView.layer.shadowOffset = CGSizeMake(-5, 0); 144 | _tempView.layer.shadowOpacity = 0.4; 145 | _tempView.layer.shadowRadius = 5; 146 | } 147 | _tempView.frame = cell.frame; 148 | [self addSubview:_tempView]; 149 | //隐藏cell 150 | cell.hidden = YES; 151 | [UIView animateWithDuration:kDH_DragableCellAnimationTime animations:^{ 152 | _tempView.center = CGPointMake(_tempView.center.x, point.y); 153 | }]; 154 | } 155 | 156 | /** 157 | 手势移动 158 | */ 159 | - (void)dh_gestureChanged:(UILongPressGestureRecognizer *)gesture 160 | { 161 | CGPoint point = [gesture locationInView:gesture.view]; 162 | //判断拖动的方向 163 | if (point.y - self.lastPoint.y > 0) { 164 | _toBottom = 1;//向下拖 165 | }else if(point.y - self.lastPoint.y < 0){ 166 | _toBottom = -1;//向上拖 167 | }else{ 168 | _toBottom = 0; 169 | } 170 | self.lastPoint = point; 171 | NSIndexPath *currentIndexPath = [self indexPathForRowAtPoint:point]; 172 | if (currentIndexPath && ![_selectedIndexPath isEqual:currentIndexPath]) { 173 | UITableViewCell *cell = [self cellForRowAtIndexPath:_selectedIndexPath]; 174 | UITableViewCell *cell1 = [self cellForRowAtIndexPath:currentIndexPath]; 175 | //将拖动的cell跟要交换的cell的centerY进行比较 176 | if ((_toBottom == 1 && (point.y+cell.frame.size.height/2) >= CGRectGetMaxY(cell1.frame) && (CGRectGetMaxY(cell1.frame) >= CGRectGetMaxY(cell.frame))) || ((_toBottom == -1 && (point.y-cell.frame.size.height/2) <= CGRectGetMinY(cell1.frame)) && (CGRectGetMinY(cell1.frame) <= CGRectGetMinY(cell.frame)))) { 177 | //交换数据源和cell 178 | [self dh_updateDataSourceAndCellFromIndexPath:_selectedIndexPath toIndexPath:currentIndexPath]; 179 | if (self.delegate && [self.delegate respondsToSelector:@selector(tableView:didMoveCellFromIndexPath:toIndexPath:)]) { 180 | [self.delegate tableView:self didMoveCellFromIndexPath:_selectedIndexPath toIndexPath:currentIndexPath]; 181 | } 182 | _selectedIndexPath = currentIndexPath; 183 | } 184 | } 185 | //让截图跟随手势 186 | _tempView.center = CGPointMake(_tempView.center.x, point.y); 187 | } 188 | 189 | /** 190 | 手势停止 191 | */ 192 | - (void)dh_gestureEndedOrCancelled:(UILongPressGestureRecognizer *)gesture 193 | { 194 | if (_canEdgeScroll) { 195 | [self dh_stopEdgeScroll]; 196 | } 197 | //返回交换后的数据源 198 | if (self.dataSource && [self.dataSource respondsToSelector:@selector(tableView:newDataSourceArrayAfterMove:)]) { 199 | [self.dataSource tableView:self newDataSourceArrayAfterMove:_tempDataSource.copy]; 200 | } 201 | if (self.delegate && [self.delegate respondsToSelector:@selector(tableView:endMoveCellAtIndexPath:)]) { 202 | [self.delegate tableView:self endMoveCellAtIndexPath:_selectedIndexPath]; 203 | } 204 | UITableViewCell *cell = [self cellForRowAtIndexPath:_selectedIndexPath]; 205 | // [UIView animateWithDuration:kDH_DragableCellAnimationTime animations:^{ 206 | // _tempView.frame = cell.frame; 207 | // } completion:^(BOOL finished) { 208 | // [_tempView removeFromSuperview]; 209 | // _tempView = nil; 210 | // cell.hidden = NO; 211 | // }]; 212 | [_tempView removeFromSuperview]; 213 | _tempView = nil; 214 | cell.hidden = NO; 215 | } 216 | 217 | #pragma mark Private action 218 | 219 | /** 220 | 截图 221 | */ 222 | - (UIView *)dh_snapshotViewWithInputView:(UIView *)inputView 223 | { 224 | UIGraphicsBeginImageContextWithOptions(inputView.bounds.size, NO, 0); 225 | [inputView.layer renderInContext:UIGraphicsGetCurrentContext()]; 226 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 227 | UIGraphicsEndImageContext(); 228 | UIView *snapshot = [[UIImageView alloc] initWithImage:image]; 229 | return snapshot; 230 | } 231 | 232 | - (void)dh_updateDataSourceAndCellFromIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath 233 | { 234 | if ([self numberOfSections] == 1) { 235 | //只有一组 236 | [_tempDataSource exchangeObjectAtIndex:fromIndexPath.row withObjectAtIndex:toIndexPath.row]; 237 | //交换cell 238 | [self moveRowAtIndexPath:fromIndexPath toIndexPath:toIndexPath]; 239 | }else { 240 | //有多组 241 | id fromData = _tempDataSource[fromIndexPath.section][fromIndexPath.row]; 242 | id toData = _tempDataSource[toIndexPath.section][toIndexPath.row]; 243 | NSMutableArray *fromArray = [_tempDataSource[fromIndexPath.section] mutableCopy]; 244 | NSMutableArray *toArray = [_tempDataSource[toIndexPath.section] mutableCopy]; 245 | [fromArray replaceObjectAtIndex:fromIndexPath.row withObject:toData]; 246 | [toArray replaceObjectAtIndex:toIndexPath.row withObject:fromData]; 247 | [_tempDataSource replaceObjectAtIndex:fromIndexPath.section withObject:fromArray]; 248 | [_tempDataSource replaceObjectAtIndex:toIndexPath.section withObject:toArray]; 249 | //交换cell 250 | [self beginUpdates]; 251 | 252 | [self moveRowAtIndexPath:fromIndexPath toIndexPath:toIndexPath]; 253 | [self moveRowAtIndexPath:toIndexPath toIndexPath:fromIndexPath]; 254 | [self endUpdates]; 255 | } 256 | //返回交换后的数据源 257 | if (self.dataSource && [self.dataSource respondsToSelector:@selector(tableView:newDataSourceArrayAfterMove:)]) { 258 | [self.dataSource tableView:self newDataSourceArrayAfterMove:_tempDataSource.copy]; 259 | } 260 | //此处用两个cell的截图实现交换的动画 261 | UITableViewCell *cell = [self cellForRowAtIndexPath:fromIndexPath]; 262 | cell.hidden = NO; 263 | UITableViewCell *cell1 = [self cellForRowAtIndexPath:toIndexPath]; 264 | cell1.hidden = YES; 265 | UIView *tmpCell = [self dh_snapshotViewWithInputView:cell]; 266 | cell.hidden = YES; 267 | tmpCell.frame = cell1.frame; 268 | if (_toBottom == -1) {//向上 269 | tmpCell.frame = CGRectMake(0, CGRectGetMinY(cell1.frame), cell.frame.size.width, cell.frame.size.height); 270 | [self insertSubview:tmpCell belowSubview:_tempView]; 271 | }else if (_toBottom == 1) {//向下 272 | tmpCell.frame = CGRectMake(0, CGRectGetMaxY(cell1.frame)-cell.frame.size.height, cell.frame.size.width, cell.frame.size.height); 273 | [self insertSubview:tmpCell belowSubview:_tempView]; 274 | }else{ 275 | } 276 | 277 | [UIView animateWithDuration:0.2 animations:^{ 278 | tmpCell.frame = cell.frame; 279 | }completion:^(BOOL finished) { 280 | cell.hidden = NO; 281 | [tmpCell removeFromSuperview]; 282 | }]; 283 | } 284 | 285 | #pragma mark EdgeScroll 286 | 287 | - (void)dh_startEdgeScroll 288 | { 289 | _edgeScrollTimer = [CADisplayLink displayLinkWithTarget:self selector:@selector(dh_processEdgeScroll)]; 290 | [_edgeScrollTimer addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; 291 | } 292 | 293 | - (void)dh_processEdgeScroll 294 | { 295 | [self dh_gestureChanged:_gesture]; 296 | CGFloat minOffsetY = self.contentOffset.y + _edgeScrollRange; 297 | CGFloat maxOffsetY = self.contentOffset.y + self.bounds.size.height - _edgeScrollRange; 298 | CGPoint touchPoint = _tempView.center; 299 | //处理上下达到极限之后不再滚动tableView,其中处理了滚动到最边缘的时候,当前处于edgeScrollRange内,但是tableView还未显示完,需要显示完tableView才停止滚动 300 | if (touchPoint.y < _edgeScrollRange) { 301 | if (self.contentOffset.y <= 0) { 302 | return; 303 | }else { 304 | if (self.contentOffset.y - 1 < 0) { 305 | return; 306 | } 307 | [self setContentOffset:CGPointMake(self.contentOffset.x, self.contentOffset.y - 1) animated:NO]; 308 | _tempView.center = CGPointMake(_tempView.center.x, _tempView.center.y - 1); 309 | } 310 | } 311 | if (touchPoint.y > self.contentSize.height - _edgeScrollRange) { 312 | if (self.contentOffset.y >= self.contentSize.height - self.bounds.size.height) { 313 | return; 314 | }else { 315 | if (self.contentOffset.y + 1 > self.contentSize.height - self.bounds.size.height) { 316 | return; 317 | } 318 | [self setContentOffset:CGPointMake(self.contentOffset.x, self.contentOffset.y + 1) animated:NO]; 319 | _tempView.center = CGPointMake(_tempView.center.x, _tempView.center.y + 1); 320 | } 321 | } 322 | //处理滚动 323 | CGFloat maxMoveDistance = 20; 324 | if (touchPoint.y < minOffsetY) { 325 | //cell在往上移动 326 | CGFloat moveDistance = (minOffsetY - touchPoint.y)/_edgeScrollRange*maxMoveDistance; 327 | [self setContentOffset:CGPointMake(self.contentOffset.x, self.contentOffset.y - moveDistance) animated:NO]; 328 | _tempView.center = CGPointMake(_tempView.center.x, _tempView.center.y - moveDistance); 329 | }else if (touchPoint.y > maxOffsetY) { 330 | //cell在往下移动 331 | CGFloat moveDistance = (touchPoint.y - maxOffsetY)/_edgeScrollRange*maxMoveDistance; 332 | [self setContentOffset:CGPointMake(self.contentOffset.x, self.contentOffset.y + moveDistance) animated:NO]; 333 | _tempView.center = CGPointMake(_tempView.center.x, _tempView.center.y + moveDistance); 334 | } 335 | } 336 | 337 | - (void)dh_stopEdgeScroll 338 | { 339 | if (_edgeScrollTimer) { 340 | [_edgeScrollTimer invalidate]; 341 | _edgeScrollTimer = nil; 342 | } 343 | } 344 | 345 | @end 346 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DHDragableCellTableView 2 | 3 | ## 安装 4 | 5 | 可以直接将DHDragableCellTableView.h文件跟DHDragableCellTableView.m文件拖到项目中,也可使用cocopods安装 6 | 7 | ``` 8 | pod 'DHDragableCellTableView' 9 | ``` 10 | 11 | ### 使用 12 | 13 | 将tableView继承于DHDragableCellTableView并遵循协议DHDragableCellTableViewDataSource,DHDragableCellTableViewDelegate 14 | 15 | 设置代理 16 | 17 | ```objc 18 | tableView.dataSource = self; 19 | tableView.Delegate = self; 20 | ``` 21 | 22 | 实现代理方法 23 | 24 | ```objc 25 | #pragma mark - DHDragableCellTableViewDataSource 26 | - (NSArray *)dataSourceArrayInTableView:(DHDragableCellTableView *)tableView{ 27 | return self.dataSource.copy;//数据源 28 | } 29 | 30 | - (void)tableView:(DHDragableCellTableView *)tableView newDataSourceArrayAfterMove:(NSArray *)newDataSourceArray{ 31 | self.dataSource = newDataSourceArray.mutableCopy;//返回的数据源 32 | [self.tableView reloadData]; 33 | } 34 | ``` 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /demo/DHDragableCellTableView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | DF89399E1EEAEF1400F4AB5E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = DF89399D1EEAEF1400F4AB5E /* main.m */; }; 11 | DF8939A11EEAEF1400F4AB5E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DF8939A01EEAEF1400F4AB5E /* AppDelegate.m */; }; 12 | DF8939A41EEAEF1400F4AB5E /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DF8939A31EEAEF1400F4AB5E /* ViewController.m */; }; 13 | DF8939A71EEAEF1400F4AB5E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DF8939A51EEAEF1400F4AB5E /* Main.storyboard */; }; 14 | DF8939A91EEAEF1400F4AB5E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DF8939A81EEAEF1400F4AB5E /* Assets.xcassets */; }; 15 | DF8939AC1EEAEF1400F4AB5E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DF8939AA1EEAEF1400F4AB5E /* LaunchScreen.storyboard */; }; 16 | DF8939B71EEAEF1400F4AB5E /* DHDragableCellTableViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DF8939B61EEAEF1400F4AB5E /* DHDragableCellTableViewTests.m */; }; 17 | DF8939C21EEAEF1400F4AB5E /* DHDragableCellTableViewUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = DF8939C11EEAEF1400F4AB5E /* DHDragableCellTableViewUITests.m */; }; 18 | DF8939D21EEAEF5300F4AB5E /* DHDragableCellTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = DF8939D11EEAEF5300F4AB5E /* DHDragableCellTableView.m */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | DF8939B31EEAEF1400F4AB5E /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = DF8939911EEAEF1400F4AB5E /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = DF8939981EEAEF1400F4AB5E; 27 | remoteInfo = DHDragableCellTableView; 28 | }; 29 | DF8939BE1EEAEF1400F4AB5E /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = DF8939911EEAEF1400F4AB5E /* Project object */; 32 | proxyType = 1; 33 | remoteGlobalIDString = DF8939981EEAEF1400F4AB5E; 34 | remoteInfo = DHDragableCellTableView; 35 | }; 36 | /* End PBXContainerItemProxy section */ 37 | 38 | /* Begin PBXFileReference section */ 39 | DF8939991EEAEF1400F4AB5E /* DHDragableCellTableView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DHDragableCellTableView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | DF89399D1EEAEF1400F4AB5E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 41 | DF89399F1EEAEF1400F4AB5E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 42 | DF8939A01EEAEF1400F4AB5E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 43 | DF8939A21EEAEF1400F4AB5E /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 44 | DF8939A31EEAEF1400F4AB5E /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 45 | DF8939A61EEAEF1400F4AB5E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 46 | DF8939A81EEAEF1400F4AB5E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 47 | DF8939AB1EEAEF1400F4AB5E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 48 | DF8939AD1EEAEF1400F4AB5E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | DF8939B21EEAEF1400F4AB5E /* DHDragableCellTableViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DHDragableCellTableViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | DF8939B61EEAEF1400F4AB5E /* DHDragableCellTableViewTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DHDragableCellTableViewTests.m; sourceTree = ""; }; 51 | DF8939B81EEAEF1400F4AB5E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | DF8939BD1EEAEF1400F4AB5E /* DHDragableCellTableViewUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DHDragableCellTableViewUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | DF8939C11EEAEF1400F4AB5E /* DHDragableCellTableViewUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DHDragableCellTableViewUITests.m; sourceTree = ""; }; 54 | DF8939C31EEAEF1400F4AB5E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | DF8939D01EEAEF5300F4AB5E /* DHDragableCellTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DHDragableCellTableView.h; sourceTree = ""; }; 56 | DF8939D11EEAEF5300F4AB5E /* DHDragableCellTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DHDragableCellTableView.m; sourceTree = ""; }; 57 | /* End PBXFileReference section */ 58 | 59 | /* Begin PBXFrameworksBuildPhase section */ 60 | DF8939961EEAEF1400F4AB5E /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | DF8939AF1EEAEF1400F4AB5E /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | DF8939BA1EEAEF1400F4AB5E /* Frameworks */ = { 75 | isa = PBXFrameworksBuildPhase; 76 | buildActionMask = 2147483647; 77 | files = ( 78 | ); 79 | runOnlyForDeploymentPostprocessing = 0; 80 | }; 81 | /* End PBXFrameworksBuildPhase section */ 82 | 83 | /* Begin PBXGroup section */ 84 | DF8939901EEAEF1400F4AB5E = { 85 | isa = PBXGroup; 86 | children = ( 87 | DF89399B1EEAEF1400F4AB5E /* DHDragableCellTableView */, 88 | DF8939B51EEAEF1400F4AB5E /* DHDragableCellTableViewTests */, 89 | DF8939C01EEAEF1400F4AB5E /* DHDragableCellTableViewUITests */, 90 | DF89399A1EEAEF1400F4AB5E /* Products */, 91 | ); 92 | sourceTree = ""; 93 | }; 94 | DF89399A1EEAEF1400F4AB5E /* Products */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | DF8939991EEAEF1400F4AB5E /* DHDragableCellTableView.app */, 98 | DF8939B21EEAEF1400F4AB5E /* DHDragableCellTableViewTests.xctest */, 99 | DF8939BD1EEAEF1400F4AB5E /* DHDragableCellTableViewUITests.xctest */, 100 | ); 101 | name = Products; 102 | sourceTree = ""; 103 | }; 104 | DF89399B1EEAEF1400F4AB5E /* DHDragableCellTableView */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | DF8939CF1EEAEF4600F4AB5E /* DHDragableCellTableView */, 108 | DF89399F1EEAEF1400F4AB5E /* AppDelegate.h */, 109 | DF8939A01EEAEF1400F4AB5E /* AppDelegate.m */, 110 | DF8939A21EEAEF1400F4AB5E /* ViewController.h */, 111 | DF8939A31EEAEF1400F4AB5E /* ViewController.m */, 112 | DF8939A51EEAEF1400F4AB5E /* Main.storyboard */, 113 | DF8939A81EEAEF1400F4AB5E /* Assets.xcassets */, 114 | DF8939AA1EEAEF1400F4AB5E /* LaunchScreen.storyboard */, 115 | DF8939AD1EEAEF1400F4AB5E /* Info.plist */, 116 | DF89399C1EEAEF1400F4AB5E /* Supporting Files */, 117 | ); 118 | path = DHDragableCellTableView; 119 | sourceTree = ""; 120 | }; 121 | DF89399C1EEAEF1400F4AB5E /* Supporting Files */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | DF89399D1EEAEF1400F4AB5E /* main.m */, 125 | ); 126 | name = "Supporting Files"; 127 | sourceTree = ""; 128 | }; 129 | DF8939B51EEAEF1400F4AB5E /* DHDragableCellTableViewTests */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | DF8939B61EEAEF1400F4AB5E /* DHDragableCellTableViewTests.m */, 133 | DF8939B81EEAEF1400F4AB5E /* Info.plist */, 134 | ); 135 | path = DHDragableCellTableViewTests; 136 | sourceTree = ""; 137 | }; 138 | DF8939C01EEAEF1400F4AB5E /* DHDragableCellTableViewUITests */ = { 139 | isa = PBXGroup; 140 | children = ( 141 | DF8939C11EEAEF1400F4AB5E /* DHDragableCellTableViewUITests.m */, 142 | DF8939C31EEAEF1400F4AB5E /* Info.plist */, 143 | ); 144 | path = DHDragableCellTableViewUITests; 145 | sourceTree = ""; 146 | }; 147 | DF8939CF1EEAEF4600F4AB5E /* DHDragableCellTableView */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | DF8939D01EEAEF5300F4AB5E /* DHDragableCellTableView.h */, 151 | DF8939D11EEAEF5300F4AB5E /* DHDragableCellTableView.m */, 152 | ); 153 | path = DHDragableCellTableView; 154 | sourceTree = ""; 155 | }; 156 | /* End PBXGroup section */ 157 | 158 | /* Begin PBXNativeTarget section */ 159 | DF8939981EEAEF1400F4AB5E /* DHDragableCellTableView */ = { 160 | isa = PBXNativeTarget; 161 | buildConfigurationList = DF8939C61EEAEF1500F4AB5E /* Build configuration list for PBXNativeTarget "DHDragableCellTableView" */; 162 | buildPhases = ( 163 | DF8939951EEAEF1400F4AB5E /* Sources */, 164 | DF8939961EEAEF1400F4AB5E /* Frameworks */, 165 | DF8939971EEAEF1400F4AB5E /* Resources */, 166 | ); 167 | buildRules = ( 168 | ); 169 | dependencies = ( 170 | ); 171 | name = DHDragableCellTableView; 172 | productName = DHDragableCellTableView; 173 | productReference = DF8939991EEAEF1400F4AB5E /* DHDragableCellTableView.app */; 174 | productType = "com.apple.product-type.application"; 175 | }; 176 | DF8939B11EEAEF1400F4AB5E /* DHDragableCellTableViewTests */ = { 177 | isa = PBXNativeTarget; 178 | buildConfigurationList = DF8939C91EEAEF1500F4AB5E /* Build configuration list for PBXNativeTarget "DHDragableCellTableViewTests" */; 179 | buildPhases = ( 180 | DF8939AE1EEAEF1400F4AB5E /* Sources */, 181 | DF8939AF1EEAEF1400F4AB5E /* Frameworks */, 182 | DF8939B01EEAEF1400F4AB5E /* Resources */, 183 | ); 184 | buildRules = ( 185 | ); 186 | dependencies = ( 187 | DF8939B41EEAEF1400F4AB5E /* PBXTargetDependency */, 188 | ); 189 | name = DHDragableCellTableViewTests; 190 | productName = DHDragableCellTableViewTests; 191 | productReference = DF8939B21EEAEF1400F4AB5E /* DHDragableCellTableViewTests.xctest */; 192 | productType = "com.apple.product-type.bundle.unit-test"; 193 | }; 194 | DF8939BC1EEAEF1400F4AB5E /* DHDragableCellTableViewUITests */ = { 195 | isa = PBXNativeTarget; 196 | buildConfigurationList = DF8939CC1EEAEF1500F4AB5E /* Build configuration list for PBXNativeTarget "DHDragableCellTableViewUITests" */; 197 | buildPhases = ( 198 | DF8939B91EEAEF1400F4AB5E /* Sources */, 199 | DF8939BA1EEAEF1400F4AB5E /* Frameworks */, 200 | DF8939BB1EEAEF1400F4AB5E /* Resources */, 201 | ); 202 | buildRules = ( 203 | ); 204 | dependencies = ( 205 | DF8939BF1EEAEF1400F4AB5E /* PBXTargetDependency */, 206 | ); 207 | name = DHDragableCellTableViewUITests; 208 | productName = DHDragableCellTableViewUITests; 209 | productReference = DF8939BD1EEAEF1400F4AB5E /* DHDragableCellTableViewUITests.xctest */; 210 | productType = "com.apple.product-type.bundle.ui-testing"; 211 | }; 212 | /* End PBXNativeTarget section */ 213 | 214 | /* Begin PBXProject section */ 215 | DF8939911EEAEF1400F4AB5E /* Project object */ = { 216 | isa = PBXProject; 217 | attributes = { 218 | LastUpgradeCheck = 0830; 219 | ORGANIZATIONNAME = aiden; 220 | TargetAttributes = { 221 | DF8939981EEAEF1400F4AB5E = { 222 | CreatedOnToolsVersion = 8.3.3; 223 | DevelopmentTeam = 2V46UE7EUZ; 224 | ProvisioningStyle = Automatic; 225 | }; 226 | DF8939B11EEAEF1400F4AB5E = { 227 | CreatedOnToolsVersion = 8.3.3; 228 | DevelopmentTeam = 2V46UE7EUZ; 229 | ProvisioningStyle = Automatic; 230 | TestTargetID = DF8939981EEAEF1400F4AB5E; 231 | }; 232 | DF8939BC1EEAEF1400F4AB5E = { 233 | CreatedOnToolsVersion = 8.3.3; 234 | DevelopmentTeam = 2V46UE7EUZ; 235 | ProvisioningStyle = Automatic; 236 | TestTargetID = DF8939981EEAEF1400F4AB5E; 237 | }; 238 | }; 239 | }; 240 | buildConfigurationList = DF8939941EEAEF1400F4AB5E /* Build configuration list for PBXProject "DHDragableCellTableView" */; 241 | compatibilityVersion = "Xcode 3.2"; 242 | developmentRegion = English; 243 | hasScannedForEncodings = 0; 244 | knownRegions = ( 245 | en, 246 | Base, 247 | ); 248 | mainGroup = DF8939901EEAEF1400F4AB5E; 249 | productRefGroup = DF89399A1EEAEF1400F4AB5E /* Products */; 250 | projectDirPath = ""; 251 | projectRoot = ""; 252 | targets = ( 253 | DF8939981EEAEF1400F4AB5E /* DHDragableCellTableView */, 254 | DF8939B11EEAEF1400F4AB5E /* DHDragableCellTableViewTests */, 255 | DF8939BC1EEAEF1400F4AB5E /* DHDragableCellTableViewUITests */, 256 | ); 257 | }; 258 | /* End PBXProject section */ 259 | 260 | /* Begin PBXResourcesBuildPhase section */ 261 | DF8939971EEAEF1400F4AB5E /* Resources */ = { 262 | isa = PBXResourcesBuildPhase; 263 | buildActionMask = 2147483647; 264 | files = ( 265 | DF8939AC1EEAEF1400F4AB5E /* LaunchScreen.storyboard in Resources */, 266 | DF8939A91EEAEF1400F4AB5E /* Assets.xcassets in Resources */, 267 | DF8939A71EEAEF1400F4AB5E /* Main.storyboard in Resources */, 268 | ); 269 | runOnlyForDeploymentPostprocessing = 0; 270 | }; 271 | DF8939B01EEAEF1400F4AB5E /* Resources */ = { 272 | isa = PBXResourcesBuildPhase; 273 | buildActionMask = 2147483647; 274 | files = ( 275 | ); 276 | runOnlyForDeploymentPostprocessing = 0; 277 | }; 278 | DF8939BB1EEAEF1400F4AB5E /* Resources */ = { 279 | isa = PBXResourcesBuildPhase; 280 | buildActionMask = 2147483647; 281 | files = ( 282 | ); 283 | runOnlyForDeploymentPostprocessing = 0; 284 | }; 285 | /* End PBXResourcesBuildPhase section */ 286 | 287 | /* Begin PBXSourcesBuildPhase section */ 288 | DF8939951EEAEF1400F4AB5E /* Sources */ = { 289 | isa = PBXSourcesBuildPhase; 290 | buildActionMask = 2147483647; 291 | files = ( 292 | DF8939A41EEAEF1400F4AB5E /* ViewController.m in Sources */, 293 | DF8939D21EEAEF5300F4AB5E /* DHDragableCellTableView.m in Sources */, 294 | DF8939A11EEAEF1400F4AB5E /* AppDelegate.m in Sources */, 295 | DF89399E1EEAEF1400F4AB5E /* main.m in Sources */, 296 | ); 297 | runOnlyForDeploymentPostprocessing = 0; 298 | }; 299 | DF8939AE1EEAEF1400F4AB5E /* Sources */ = { 300 | isa = PBXSourcesBuildPhase; 301 | buildActionMask = 2147483647; 302 | files = ( 303 | DF8939B71EEAEF1400F4AB5E /* DHDragableCellTableViewTests.m in Sources */, 304 | ); 305 | runOnlyForDeploymentPostprocessing = 0; 306 | }; 307 | DF8939B91EEAEF1400F4AB5E /* Sources */ = { 308 | isa = PBXSourcesBuildPhase; 309 | buildActionMask = 2147483647; 310 | files = ( 311 | DF8939C21EEAEF1400F4AB5E /* DHDragableCellTableViewUITests.m in Sources */, 312 | ); 313 | runOnlyForDeploymentPostprocessing = 0; 314 | }; 315 | /* End PBXSourcesBuildPhase section */ 316 | 317 | /* Begin PBXTargetDependency section */ 318 | DF8939B41EEAEF1400F4AB5E /* PBXTargetDependency */ = { 319 | isa = PBXTargetDependency; 320 | target = DF8939981EEAEF1400F4AB5E /* DHDragableCellTableView */; 321 | targetProxy = DF8939B31EEAEF1400F4AB5E /* PBXContainerItemProxy */; 322 | }; 323 | DF8939BF1EEAEF1400F4AB5E /* PBXTargetDependency */ = { 324 | isa = PBXTargetDependency; 325 | target = DF8939981EEAEF1400F4AB5E /* DHDragableCellTableView */; 326 | targetProxy = DF8939BE1EEAEF1400F4AB5E /* PBXContainerItemProxy */; 327 | }; 328 | /* End PBXTargetDependency section */ 329 | 330 | /* Begin PBXVariantGroup section */ 331 | DF8939A51EEAEF1400F4AB5E /* Main.storyboard */ = { 332 | isa = PBXVariantGroup; 333 | children = ( 334 | DF8939A61EEAEF1400F4AB5E /* Base */, 335 | ); 336 | name = Main.storyboard; 337 | sourceTree = ""; 338 | }; 339 | DF8939AA1EEAEF1400F4AB5E /* LaunchScreen.storyboard */ = { 340 | isa = PBXVariantGroup; 341 | children = ( 342 | DF8939AB1EEAEF1400F4AB5E /* Base */, 343 | ); 344 | name = LaunchScreen.storyboard; 345 | sourceTree = ""; 346 | }; 347 | /* End PBXVariantGroup section */ 348 | 349 | /* Begin XCBuildConfiguration section */ 350 | DF8939C41EEAEF1500F4AB5E /* Debug */ = { 351 | isa = XCBuildConfiguration; 352 | buildSettings = { 353 | ALWAYS_SEARCH_USER_PATHS = NO; 354 | CLANG_ANALYZER_NONNULL = YES; 355 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 356 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 357 | CLANG_CXX_LIBRARY = "libc++"; 358 | CLANG_ENABLE_MODULES = YES; 359 | CLANG_ENABLE_OBJC_ARC = YES; 360 | CLANG_WARN_BOOL_CONVERSION = YES; 361 | CLANG_WARN_CONSTANT_CONVERSION = YES; 362 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 363 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 364 | CLANG_WARN_EMPTY_BODY = YES; 365 | CLANG_WARN_ENUM_CONVERSION = YES; 366 | CLANG_WARN_INFINITE_RECURSION = YES; 367 | CLANG_WARN_INT_CONVERSION = YES; 368 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 369 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 370 | CLANG_WARN_UNREACHABLE_CODE = YES; 371 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 372 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 373 | COPY_PHASE_STRIP = NO; 374 | DEBUG_INFORMATION_FORMAT = dwarf; 375 | ENABLE_STRICT_OBJC_MSGSEND = YES; 376 | ENABLE_TESTABILITY = YES; 377 | GCC_C_LANGUAGE_STANDARD = gnu99; 378 | GCC_DYNAMIC_NO_PIC = NO; 379 | GCC_NO_COMMON_BLOCKS = YES; 380 | GCC_OPTIMIZATION_LEVEL = 0; 381 | GCC_PREPROCESSOR_DEFINITIONS = ( 382 | "DEBUG=1", 383 | "$(inherited)", 384 | ); 385 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 386 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 387 | GCC_WARN_UNDECLARED_SELECTOR = YES; 388 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 389 | GCC_WARN_UNUSED_FUNCTION = YES; 390 | GCC_WARN_UNUSED_VARIABLE = YES; 391 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 392 | MTL_ENABLE_DEBUG_INFO = YES; 393 | ONLY_ACTIVE_ARCH = YES; 394 | SDKROOT = iphoneos; 395 | }; 396 | name = Debug; 397 | }; 398 | DF8939C51EEAEF1500F4AB5E /* Release */ = { 399 | isa = XCBuildConfiguration; 400 | buildSettings = { 401 | ALWAYS_SEARCH_USER_PATHS = NO; 402 | CLANG_ANALYZER_NONNULL = YES; 403 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 404 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 405 | CLANG_CXX_LIBRARY = "libc++"; 406 | CLANG_ENABLE_MODULES = YES; 407 | CLANG_ENABLE_OBJC_ARC = YES; 408 | CLANG_WARN_BOOL_CONVERSION = YES; 409 | CLANG_WARN_CONSTANT_CONVERSION = YES; 410 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 411 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 412 | CLANG_WARN_EMPTY_BODY = YES; 413 | CLANG_WARN_ENUM_CONVERSION = YES; 414 | CLANG_WARN_INFINITE_RECURSION = YES; 415 | CLANG_WARN_INT_CONVERSION = YES; 416 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 417 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 418 | CLANG_WARN_UNREACHABLE_CODE = YES; 419 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 420 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 421 | COPY_PHASE_STRIP = NO; 422 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 423 | ENABLE_NS_ASSERTIONS = NO; 424 | ENABLE_STRICT_OBJC_MSGSEND = YES; 425 | GCC_C_LANGUAGE_STANDARD = gnu99; 426 | GCC_NO_COMMON_BLOCKS = YES; 427 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 428 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 429 | GCC_WARN_UNDECLARED_SELECTOR = YES; 430 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 431 | GCC_WARN_UNUSED_FUNCTION = YES; 432 | GCC_WARN_UNUSED_VARIABLE = YES; 433 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 434 | MTL_ENABLE_DEBUG_INFO = NO; 435 | SDKROOT = iphoneos; 436 | VALIDATE_PRODUCT = YES; 437 | }; 438 | name = Release; 439 | }; 440 | DF8939C71EEAEF1500F4AB5E /* Debug */ = { 441 | isa = XCBuildConfiguration; 442 | buildSettings = { 443 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 444 | DEVELOPMENT_TEAM = 2V46UE7EUZ; 445 | INFOPLIST_FILE = DHDragableCellTableView/Info.plist; 446 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 447 | PRODUCT_BUNDLE_IDENTIFIER = com.aiden.DHDragableCellTableView; 448 | PRODUCT_NAME = "$(TARGET_NAME)"; 449 | }; 450 | name = Debug; 451 | }; 452 | DF8939C81EEAEF1500F4AB5E /* Release */ = { 453 | isa = XCBuildConfiguration; 454 | buildSettings = { 455 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 456 | DEVELOPMENT_TEAM = 2V46UE7EUZ; 457 | INFOPLIST_FILE = DHDragableCellTableView/Info.plist; 458 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 459 | PRODUCT_BUNDLE_IDENTIFIER = com.aiden.DHDragableCellTableView; 460 | PRODUCT_NAME = "$(TARGET_NAME)"; 461 | }; 462 | name = Release; 463 | }; 464 | DF8939CA1EEAEF1500F4AB5E /* Debug */ = { 465 | isa = XCBuildConfiguration; 466 | buildSettings = { 467 | BUNDLE_LOADER = "$(TEST_HOST)"; 468 | DEVELOPMENT_TEAM = 2V46UE7EUZ; 469 | INFOPLIST_FILE = DHDragableCellTableViewTests/Info.plist; 470 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 471 | PRODUCT_BUNDLE_IDENTIFIER = com.aiden.DHDragableCellTableViewTests; 472 | PRODUCT_NAME = "$(TARGET_NAME)"; 473 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DHDragableCellTableView.app/DHDragableCellTableView"; 474 | }; 475 | name = Debug; 476 | }; 477 | DF8939CB1EEAEF1500F4AB5E /* Release */ = { 478 | isa = XCBuildConfiguration; 479 | buildSettings = { 480 | BUNDLE_LOADER = "$(TEST_HOST)"; 481 | DEVELOPMENT_TEAM = 2V46UE7EUZ; 482 | INFOPLIST_FILE = DHDragableCellTableViewTests/Info.plist; 483 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 484 | PRODUCT_BUNDLE_IDENTIFIER = com.aiden.DHDragableCellTableViewTests; 485 | PRODUCT_NAME = "$(TARGET_NAME)"; 486 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DHDragableCellTableView.app/DHDragableCellTableView"; 487 | }; 488 | name = Release; 489 | }; 490 | DF8939CD1EEAEF1500F4AB5E /* Debug */ = { 491 | isa = XCBuildConfiguration; 492 | buildSettings = { 493 | DEVELOPMENT_TEAM = 2V46UE7EUZ; 494 | INFOPLIST_FILE = DHDragableCellTableViewUITests/Info.plist; 495 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 496 | PRODUCT_BUNDLE_IDENTIFIER = com.aiden.DHDragableCellTableViewUITests; 497 | PRODUCT_NAME = "$(TARGET_NAME)"; 498 | TEST_TARGET_NAME = DHDragableCellTableView; 499 | }; 500 | name = Debug; 501 | }; 502 | DF8939CE1EEAEF1500F4AB5E /* Release */ = { 503 | isa = XCBuildConfiguration; 504 | buildSettings = { 505 | DEVELOPMENT_TEAM = 2V46UE7EUZ; 506 | INFOPLIST_FILE = DHDragableCellTableViewUITests/Info.plist; 507 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 508 | PRODUCT_BUNDLE_IDENTIFIER = com.aiden.DHDragableCellTableViewUITests; 509 | PRODUCT_NAME = "$(TARGET_NAME)"; 510 | TEST_TARGET_NAME = DHDragableCellTableView; 511 | }; 512 | name = Release; 513 | }; 514 | /* End XCBuildConfiguration section */ 515 | 516 | /* Begin XCConfigurationList section */ 517 | DF8939941EEAEF1400F4AB5E /* Build configuration list for PBXProject "DHDragableCellTableView" */ = { 518 | isa = XCConfigurationList; 519 | buildConfigurations = ( 520 | DF8939C41EEAEF1500F4AB5E /* Debug */, 521 | DF8939C51EEAEF1500F4AB5E /* Release */, 522 | ); 523 | defaultConfigurationIsVisible = 0; 524 | defaultConfigurationName = Release; 525 | }; 526 | DF8939C61EEAEF1500F4AB5E /* Build configuration list for PBXNativeTarget "DHDragableCellTableView" */ = { 527 | isa = XCConfigurationList; 528 | buildConfigurations = ( 529 | DF8939C71EEAEF1500F4AB5E /* Debug */, 530 | DF8939C81EEAEF1500F4AB5E /* Release */, 531 | ); 532 | defaultConfigurationIsVisible = 0; 533 | }; 534 | DF8939C91EEAEF1500F4AB5E /* Build configuration list for PBXNativeTarget "DHDragableCellTableViewTests" */ = { 535 | isa = XCConfigurationList; 536 | buildConfigurations = ( 537 | DF8939CA1EEAEF1500F4AB5E /* Debug */, 538 | DF8939CB1EEAEF1500F4AB5E /* Release */, 539 | ); 540 | defaultConfigurationIsVisible = 0; 541 | }; 542 | DF8939CC1EEAEF1500F4AB5E /* Build configuration list for PBXNativeTarget "DHDragableCellTableViewUITests" */ = { 543 | isa = XCConfigurationList; 544 | buildConfigurations = ( 545 | DF8939CD1EEAEF1500F4AB5E /* Debug */, 546 | DF8939CE1EEAEF1500F4AB5E /* Release */, 547 | ); 548 | defaultConfigurationIsVisible = 0; 549 | }; 550 | /* End XCConfigurationList section */ 551 | }; 552 | rootObject = DF8939911EEAEF1400F4AB5E /* Project object */; 553 | } 554 | -------------------------------------------------------------------------------- /demo/DHDragableCellTableView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /demo/DHDragableCellTableView/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // DHDragableCellTableView 4 | // 5 | // Created by aiden on 2017/6/9. 6 | // Copyright © 2017年 aiden. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /demo/DHDragableCellTableView/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // DHDragableCellTableView 4 | // 5 | // Created by aiden on 2017/6/9. 6 | // Copyright © 2017年 aiden. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /demo/DHDragableCellTableView/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /demo/DHDragableCellTableView/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /demo/DHDragableCellTableView/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /demo/DHDragableCellTableView/DHDragableCellTableView/DHDragableCellTableView.h: -------------------------------------------------------------------------------- 1 | // 2 | // DHDragableCellTableView.h 3 | // DHDragableCellTableView 4 | // 5 | // Created by jiaxin on 16/2/15. 6 | // Copyright © 2016年 jiaxin. All rights reserved. 7 | // 8 | 9 | #import 10 | @class DHDragableCellTableView; 11 | 12 | @protocol DHDragableCellTableViewDataSource 13 | 14 | @required 15 | 16 | /** 17 | 获取tableView的数据源数组 18 | */ 19 | - (NSArray *)dataSourceArrayInTableView:(DHDragableCellTableView *)tableView; 20 | /** 21 | 返回移动之后调换后的数据源 22 | */ 23 | - (void)tableView:(DHDragableCellTableView *)tableView newDataSourceArrayAfterMove:(NSArray *)newDataSourceArray; 24 | 25 | @end 26 | 27 | @protocol DHDragableCellTableViewDelegate 28 | @optional 29 | /** 30 | 将要开始移动indexPath位置的cell 31 | */ 32 | - (void)tableView:(DHDragableCellTableView *)tableView willMoveCellAtIndexPath:(NSIndexPath *)indexPath; 33 | /** 34 | 完成一次从fromIndexPath cell到toIndexPath cell的移动 35 | */ 36 | - (void)tableView:(DHDragableCellTableView *)tableView didMoveCellFromIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath; 37 | /** 38 | 结束移动cell在indexPath 39 | */ 40 | - (void)tableView:(DHDragableCellTableView *)tableView endMoveCellAtIndexPath:(NSIndexPath *)indexPath; 41 | 42 | @end 43 | 44 | @interface DHDragableCellTableView : UITableView 45 | 46 | @property (nonatomic, weak) id dataSource; 47 | @property (nonatomic, weak) id delegate; 48 | /** 49 | 长按手势最小触发时间,默认1.0,最小0.2 50 | */ 51 | @property (nonatomic, assign) CGFloat gestureMinimumPressDuration; 52 | /** 53 | 自定义可移动cell的截图样式 54 | */ 55 | @property (nonatomic, copy) void (^drawMovalbeCellBlock)(UIView *DragableCell); 56 | /** 57 | 是否允许拖动到屏幕边缘后,开启边缘滚动,默认YES 58 | */ 59 | @property (nonatomic, assign) BOOL canEdgeScroll; 60 | /** 61 | 边缘滚动触发范围,默认150,越靠近边缘速度越快 62 | */ 63 | @property (nonatomic, assign) CGFloat edgeScrollRange; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /demo/DHDragableCellTableView/DHDragableCellTableView/DHDragableCellTableView.m: -------------------------------------------------------------------------------- 1 | // 2 | // DH_DragableCellTableView.m 3 | // DH_DragableCellTableView 4 | // 5 | // Created by jiaxin on 16/2/15. 6 | // Copyright © 2016年 jiaxin. All rights reserved. 7 | // 8 | 9 | #import "DHDragableCellTableView.h" 10 | 11 | static NSTimeInterval kDH_DragableCellAnimationTime = 0.25; 12 | 13 | @interface DHDragableCellTableView () 14 | @property (nonatomic, strong) UILongPressGestureRecognizer *gesture; 15 | @property (nonatomic, strong) NSIndexPath *selectedIndexPath; 16 | @property (nonatomic, strong) UIView *tempView; 17 | @property (nonatomic, strong) NSMutableArray *tempDataSource; 18 | @property (nonatomic, strong) CADisplayLink *edgeScrollTimer; 19 | @property (nonatomic, assign) CGPoint lastPoint; 20 | @property (nonatomic, assign) int toBottom; 21 | @end 22 | 23 | @implementation DHDragableCellTableView 24 | 25 | @dynamic dataSource, delegate; 26 | 27 | - (void)dealloc 28 | { 29 | _drawMovalbeCellBlock = nil; 30 | } 31 | 32 | - (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style 33 | { 34 | self = [super initWithFrame:frame style:style]; 35 | if (self) { 36 | [self dh_initData]; 37 | [self dh_addGesture]; 38 | } 39 | return self; 40 | } 41 | 42 | - (instancetype)initWithCoder:(NSCoder *)aDecoder 43 | { 44 | self = [super initWithCoder:aDecoder]; 45 | if (self) { 46 | [self dh_initData]; 47 | [self dh_addGesture]; 48 | } 49 | return self; 50 | } 51 | 52 | - (void)dh_initData 53 | { 54 | _gestureMinimumPressDuration = 1.0f; 55 | _canEdgeScroll = YES; 56 | _edgeScrollRange = 150.f; 57 | } 58 | 59 | #pragma mark Setter 60 | /** 61 | 设置长按时间 62 | */ 63 | - (void)setGestureMinimumPressDuration:(CGFloat)gestureMinimumPressDuration 64 | { 65 | _gestureMinimumPressDuration = gestureMinimumPressDuration; 66 | _gesture.minimumPressDuration = MAX(0.2, gestureMinimumPressDuration); 67 | } 68 | 69 | #pragma mark Gesture 70 | 71 | /** 72 | 添加手势 73 | */ 74 | - (void)dh_addGesture 75 | { 76 | _gesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(dh_processGesture:)]; 77 | _gesture.minimumPressDuration = _gestureMinimumPressDuration; 78 | [self addGestureRecognizer:_gesture]; 79 | } 80 | 81 | /** 82 | 监听手势状态 83 | */ 84 | - (void)dh_processGesture:(UILongPressGestureRecognizer *)gesture 85 | { 86 | switch (gesture.state) { 87 | case UIGestureRecognizerStateBegan: 88 | { 89 | [self dh_gestureBegan:gesture]; 90 | } 91 | break; 92 | case UIGestureRecognizerStateChanged: 93 | { 94 | if (!_canEdgeScroll) { 95 | [self dh_gestureChanged:gesture]; 96 | } 97 | } 98 | break; 99 | case UIGestureRecognizerStateEnded: 100 | case UIGestureRecognizerStateCancelled: 101 | { 102 | [self dh_gestureEndedOrCancelled:gesture]; 103 | } 104 | break; 105 | default: 106 | break; 107 | } 108 | } 109 | 110 | /** 111 | 开始移动 112 | */ 113 | - (void)dh_gestureBegan:(UILongPressGestureRecognizer *)gesture 114 | { 115 | CGPoint point = [gesture locationInView:gesture.view]; 116 | self.lastPoint = point; 117 | NSIndexPath *selectedIndexPath = [self indexPathForRowAtPoint:point]; 118 | if (!selectedIndexPath) { 119 | return; 120 | } 121 | if (self.delegate && [self.delegate respondsToSelector:@selector(tableView:willMoveCellAtIndexPath:)]) { 122 | [self.delegate tableView:self willMoveCellAtIndexPath:selectedIndexPath]; 123 | } 124 | if (_canEdgeScroll) { 125 | //开启边缘滚动 126 | [self dh_startEdgeScroll]; 127 | } 128 | //每次移动开始获取一次数据源 129 | if (self.dataSource && [self.dataSource respondsToSelector:@selector(dataSourceArrayInTableView:)]) { 130 | _tempDataSource = [self.dataSource dataSourceArrayInTableView:self].mutableCopy; 131 | } 132 | _selectedIndexPath = selectedIndexPath; 133 | UITableViewCell *cell = [self cellForRowAtIndexPath:selectedIndexPath]; 134 | _tempView = [self dh_snapshotViewWithInputView:cell]; 135 | if (_drawMovalbeCellBlock) { 136 | //将_tempView通过block让使用者自定义 137 | _drawMovalbeCellBlock(_tempView); 138 | }else { 139 | //配置默认样式 140 | _tempView.layer.shadowColor = [UIColor grayColor].CGColor; 141 | _tempView.layer.masksToBounds = NO; 142 | _tempView.layer.cornerRadius = 0; 143 | _tempView.layer.shadowOffset = CGSizeMake(-5, 0); 144 | _tempView.layer.shadowOpacity = 0.4; 145 | _tempView.layer.shadowRadius = 5; 146 | } 147 | _tempView.frame = cell.frame; 148 | [self addSubview:_tempView]; 149 | //隐藏cell 150 | cell.hidden = YES; 151 | [UIView animateWithDuration:kDH_DragableCellAnimationTime animations:^{ 152 | _tempView.center = CGPointMake(_tempView.center.x, point.y); 153 | }]; 154 | } 155 | 156 | /** 157 | 手势移动 158 | */ 159 | - (void)dh_gestureChanged:(UILongPressGestureRecognizer *)gesture 160 | { 161 | CGPoint point = [gesture locationInView:gesture.view]; 162 | //判断拖动的方向 163 | if (point.y - self.lastPoint.y > 0) { 164 | _toBottom = 1;//向下拖 165 | }else if(point.y - self.lastPoint.y < 0){ 166 | _toBottom = -1;//向上拖 167 | }else{ 168 | _toBottom = 0; 169 | } 170 | self.lastPoint = point; 171 | NSIndexPath *currentIndexPath = [self indexPathForRowAtPoint:point]; 172 | if (currentIndexPath && ![_selectedIndexPath isEqual:currentIndexPath]) { 173 | UITableViewCell *cell = [self cellForRowAtIndexPath:_selectedIndexPath]; 174 | UITableViewCell *cell1 = [self cellForRowAtIndexPath:currentIndexPath]; 175 | //将拖动的cell跟要交换的cell的centerY进行比较 176 | if ((_toBottom == 1 && (point.y+cell.frame.size.height/2) >= CGRectGetMaxY(cell1.frame) && (CGRectGetMaxY(cell1.frame) >= CGRectGetMaxY(cell.frame))) || ((_toBottom == -1 && (point.y-cell.frame.size.height/2) <= CGRectGetMinY(cell1.frame)) && (CGRectGetMinY(cell1.frame) <= CGRectGetMinY(cell.frame)))) { 177 | //交换数据源和cell 178 | [self dh_updateDataSourceAndCellFromIndexPath:_selectedIndexPath toIndexPath:currentIndexPath]; 179 | if (self.delegate && [self.delegate respondsToSelector:@selector(tableView:didMoveCellFromIndexPath:toIndexPath:)]) { 180 | [self.delegate tableView:self didMoveCellFromIndexPath:_selectedIndexPath toIndexPath:currentIndexPath]; 181 | } 182 | _selectedIndexPath = currentIndexPath; 183 | } 184 | } 185 | //让截图跟随手势 186 | _tempView.center = CGPointMake(_tempView.center.x, point.y); 187 | } 188 | 189 | /** 190 | 手势停止 191 | */ 192 | - (void)dh_gestureEndedOrCancelled:(UILongPressGestureRecognizer *)gesture 193 | { 194 | if (_canEdgeScroll) { 195 | [self dh_stopEdgeScroll]; 196 | } 197 | //返回交换后的数据源 198 | if (self.dataSource && [self.dataSource respondsToSelector:@selector(tableView:newDataSourceArrayAfterMove:)]) { 199 | [self.dataSource tableView:self newDataSourceArrayAfterMove:_tempDataSource.copy]; 200 | } 201 | if (self.delegate && [self.delegate respondsToSelector:@selector(tableView:endMoveCellAtIndexPath:)]) { 202 | [self.delegate tableView:self endMoveCellAtIndexPath:_selectedIndexPath]; 203 | } 204 | UITableViewCell *cell = [self cellForRowAtIndexPath:_selectedIndexPath]; 205 | // [UIView animateWithDuration:kDH_DragableCellAnimationTime animations:^{ 206 | // _tempView.frame = cell.frame; 207 | // } completion:^(BOOL finished) { 208 | // [_tempView removeFromSuperview]; 209 | // _tempView = nil; 210 | // cell.hidden = NO; 211 | // }]; 212 | [_tempView removeFromSuperview]; 213 | _tempView = nil; 214 | cell.hidden = NO; 215 | } 216 | 217 | #pragma mark Private action 218 | 219 | /** 220 | 截图 221 | */ 222 | - (UIView *)dh_snapshotViewWithInputView:(UIView *)inputView 223 | { 224 | UIGraphicsBeginImageContextWithOptions(inputView.bounds.size, NO, 0); 225 | [inputView.layer renderInContext:UIGraphicsGetCurrentContext()]; 226 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 227 | UIGraphicsEndImageContext(); 228 | UIView *snapshot = [[UIImageView alloc] initWithImage:image]; 229 | return snapshot; 230 | } 231 | 232 | - (void)dh_updateDataSourceAndCellFromIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath 233 | { 234 | if ([self numberOfSections] == 1) { 235 | //只有一组 236 | [_tempDataSource exchangeObjectAtIndex:fromIndexPath.row withObjectAtIndex:toIndexPath.row]; 237 | //交换cell 238 | [self moveRowAtIndexPath:fromIndexPath toIndexPath:toIndexPath]; 239 | }else { 240 | //有多组 241 | id fromData = _tempDataSource[fromIndexPath.section][fromIndexPath.row]; 242 | id toData = _tempDataSource[toIndexPath.section][toIndexPath.row]; 243 | NSMutableArray *fromArray = [_tempDataSource[fromIndexPath.section] mutableCopy]; 244 | NSMutableArray *toArray = [_tempDataSource[toIndexPath.section] mutableCopy]; 245 | [fromArray replaceObjectAtIndex:fromIndexPath.row withObject:toData]; 246 | [toArray replaceObjectAtIndex:toIndexPath.row withObject:fromData]; 247 | [_tempDataSource replaceObjectAtIndex:fromIndexPath.section withObject:fromArray]; 248 | [_tempDataSource replaceObjectAtIndex:toIndexPath.section withObject:toArray]; 249 | //交换cell 250 | [self beginUpdates]; 251 | 252 | [self moveRowAtIndexPath:fromIndexPath toIndexPath:toIndexPath]; 253 | [self moveRowAtIndexPath:toIndexPath toIndexPath:fromIndexPath]; 254 | [self endUpdates]; 255 | } 256 | //返回交换后的数据源 257 | if (self.dataSource && [self.dataSource respondsToSelector:@selector(tableView:newDataSourceArrayAfterMove:)]) { 258 | [self.dataSource tableView:self newDataSourceArrayAfterMove:_tempDataSource.copy]; 259 | } 260 | //此处用两个cell的截图实现交换的动画 261 | UITableViewCell *cell = [self cellForRowAtIndexPath:fromIndexPath]; 262 | cell.hidden = NO; 263 | UITableViewCell *cell1 = [self cellForRowAtIndexPath:toIndexPath]; 264 | cell1.hidden = YES; 265 | UIView *tmpCell = [self dh_snapshotViewWithInputView:cell]; 266 | cell.hidden = YES; 267 | tmpCell.frame = cell1.frame; 268 | if (_toBottom == -1) {//向上 269 | tmpCell.frame = CGRectMake(0, CGRectGetMinY(cell1.frame), cell.frame.size.width, cell.frame.size.height); 270 | [self insertSubview:tmpCell belowSubview:_tempView]; 271 | }else if (_toBottom == 1) {//向下 272 | tmpCell.frame = CGRectMake(0, CGRectGetMaxY(cell1.frame)-cell.frame.size.height, cell.frame.size.width, cell.frame.size.height); 273 | [self insertSubview:tmpCell belowSubview:_tempView]; 274 | }else{ 275 | } 276 | 277 | [UIView animateWithDuration:0.2 animations:^{ 278 | tmpCell.frame = cell.frame; 279 | }completion:^(BOOL finished) { 280 | cell.hidden = NO; 281 | [tmpCell removeFromSuperview]; 282 | }]; 283 | } 284 | 285 | #pragma mark EdgeScroll 286 | 287 | - (void)dh_startEdgeScroll 288 | { 289 | _edgeScrollTimer = [CADisplayLink displayLinkWithTarget:self selector:@selector(dh_processEdgeScroll)]; 290 | [_edgeScrollTimer addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; 291 | } 292 | 293 | - (void)dh_processEdgeScroll 294 | { 295 | [self dh_gestureChanged:_gesture]; 296 | CGFloat minOffsetY = self.contentOffset.y + _edgeScrollRange; 297 | CGFloat maxOffsetY = self.contentOffset.y + self.bounds.size.height - _edgeScrollRange; 298 | CGPoint touchPoint = _tempView.center; 299 | //处理上下达到极限之后不再滚动tableView,其中处理了滚动到最边缘的时候,当前处于edgeScrollRange内,但是tableView还未显示完,需要显示完tableView才停止滚动 300 | if (touchPoint.y < _edgeScrollRange) { 301 | if (self.contentOffset.y <= 0) { 302 | return; 303 | }else { 304 | if (self.contentOffset.y - 1 < 0) { 305 | return; 306 | } 307 | [self setContentOffset:CGPointMake(self.contentOffset.x, self.contentOffset.y - 1) animated:NO]; 308 | _tempView.center = CGPointMake(_tempView.center.x, _tempView.center.y - 1); 309 | } 310 | } 311 | if (touchPoint.y > self.contentSize.height - _edgeScrollRange) { 312 | if (self.contentOffset.y >= self.contentSize.height - self.bounds.size.height) { 313 | return; 314 | }else { 315 | if (self.contentOffset.y + 1 > self.contentSize.height - self.bounds.size.height) { 316 | return; 317 | } 318 | [self setContentOffset:CGPointMake(self.contentOffset.x, self.contentOffset.y + 1) animated:NO]; 319 | _tempView.center = CGPointMake(_tempView.center.x, _tempView.center.y + 1); 320 | } 321 | } 322 | //处理滚动 323 | CGFloat maxMoveDistance = 20; 324 | if (touchPoint.y < minOffsetY) { 325 | //cell在往上移动 326 | CGFloat moveDistance = (minOffsetY - touchPoint.y)/_edgeScrollRange*maxMoveDistance; 327 | [self setContentOffset:CGPointMake(self.contentOffset.x, self.contentOffset.y - moveDistance) animated:NO]; 328 | _tempView.center = CGPointMake(_tempView.center.x, _tempView.center.y - moveDistance); 329 | }else if (touchPoint.y > maxOffsetY) { 330 | //cell在往下移动 331 | CGFloat moveDistance = (touchPoint.y - maxOffsetY)/_edgeScrollRange*maxMoveDistance; 332 | [self setContentOffset:CGPointMake(self.contentOffset.x, self.contentOffset.y + moveDistance) animated:NO]; 333 | _tempView.center = CGPointMake(_tempView.center.x, _tempView.center.y + moveDistance); 334 | } 335 | } 336 | 337 | - (void)dh_stopEdgeScroll 338 | { 339 | if (_edgeScrollTimer) { 340 | [_edgeScrollTimer invalidate]; 341 | _edgeScrollTimer = nil; 342 | } 343 | } 344 | 345 | @end 346 | -------------------------------------------------------------------------------- /demo/DHDragableCellTableView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /demo/DHDragableCellTableView/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // DHDragableCellTableView 4 | // 5 | // Created by aiden on 2017/6/9. 6 | // Copyright © 2017年 aiden. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /demo/DHDragableCellTableView/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // DHDragableCellTableView 4 | // 5 | // Created by aiden on 2017/6/9. 6 | // Copyright © 2017年 aiden. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "DHDragableCellTableView.h" 11 | 12 | @interface ViewController () 13 | @property (nonatomic, strong) DHDragableCellTableView *tableView; 14 | @property (nonatomic ,strong) NSMutableArray *dataSource; 15 | @end 16 | 17 | @implementation ViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | // Do any additional setup after loading the view, typically from a nib. 22 | [self.view addSubview:self.tableView ]; 23 | } 24 | 25 | #pragma mark - UITableViewDataSource 26 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 27 | return self.dataSource.count; 28 | } 29 | 30 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 31 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; 32 | cell.textLabel.text = [NSString stringWithFormat:@"cell高度为%d",[self.dataSource[indexPath.row] intValue]]; 33 | return cell; 34 | } 35 | 36 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ 37 | return [self.dataSource[indexPath.row] floatValue]; 38 | } 39 | 40 | #pragma mark - DHDragableCellTableViewDataSource 41 | - (NSArray *)dataSourceArrayInTableView:(DHDragableCellTableView *)tableView{ 42 | return self.dataSource.copy; 43 | } 44 | 45 | - (void)tableView:(DHDragableCellTableView *)tableView newDataSourceArrayAfterMove:(NSArray *)newDataSourceArray{ 46 | self.dataSource = newDataSourceArray.mutableCopy; 47 | [self.tableView reloadData]; 48 | } 49 | #pragma mark - getter 50 | - (DHDragableCellTableView *)tableView{ 51 | if (!_tableView) { 52 | _tableView = [[DHDragableCellTableView alloc] initWithFrame:self.view.bounds]; 53 | [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"]; 54 | _tableView.dataSource = self; 55 | _tableView.delegate = self; 56 | } 57 | return _tableView; 58 | } 59 | 60 | - (NSMutableArray *)dataSource{ 61 | if (!_dataSource) { 62 | _dataSource = @[@50,@60,@70,@80,@90,@100,@110,@120,@130,@140,@150].mutableCopy; 63 | } 64 | return _dataSource; 65 | } 66 | @end 67 | -------------------------------------------------------------------------------- /demo/DHDragableCellTableView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // DHDragableCellTableView 4 | // 5 | // Created by aiden on 2017/6/9. 6 | // Copyright © 2017年 aiden. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /demo/DHDragableCellTableViewTests/DHDragableCellTableViewTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // DHDragableCellTableViewTests.m 3 | // DHDragableCellTableViewTests 4 | // 5 | // Created by aiden on 2017/6/9. 6 | // Copyright © 2017年 aiden. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DHDragableCellTableViewTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation DHDragableCellTableViewTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /demo/DHDragableCellTableViewTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /demo/DHDragableCellTableViewUITests/DHDragableCellTableViewUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // DHDragableCellTableViewUITests.m 3 | // DHDragableCellTableViewUITests 4 | // 5 | // Created by aiden on 2017/6/9. 6 | // Copyright © 2017年 aiden. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DHDragableCellTableViewUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation DHDragableCellTableViewUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /demo/DHDragableCellTableViewUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | --------------------------------------------------------------------------------