源码简介
MGSwipeTableCell是UITableViewCell的子类,用多种过渡方式展示可点击的按钮,该库兼容所有不同的方式来创建UITableViewCell。
源码运行截图
源码片段
- #pragma mark Trigger Actions
- -(void) handleClick: (id) sender fromExpansion:(BOOL) fromExpansion
- {
- bool autoHide = false;
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wundeclared-selector"
- if ([sender respondsToSelector:@selector(callMGSwipeConvenienceCallback:)]) {
- //call convenience block callback if exits (usage of MGSwipeButton class is not compulsory)
- autoHide = [sender performSelector:@selector(callMGSwipeConvenienceCallback:) withObject:_cell];
- }
- #pragma clang diagnostic pop
- if (_cell.delegate && [_cell.delegate respondsToSelector:@selector(swipeTableCell:tappedButtonAtIndex:direction:fromExpansion:)]) {
- NSInteger index = [_buttons indexOfObject:sender];
- if (!_fromLeft) {
- index = _buttons.count - index - 1; //right buttons are reversed
- }
- autoHide|= [_cell.delegate swipeTableCell:_cell tappedButtonAtIndex:index direction:_fromLeft ? MGSwipeDirectionLeftToRight : MGSwipeDirectionRightToLeft fromExpansion:fromExpansion];
- }
- if (fromExpansion) {
- _expandedButton = nil;
- _cell.swipeOffset = 0;
- }
- else if (autoHide) {
- [_cell hideSwipeAnimated:YES];
- }
- }