Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed invalid next responder check if not found #233

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion RETableViewManager/RETableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ - (void)cellWillAppear
self.textLabel.backgroundColor = [UIColor clearColor];
self.accessoryType = item.accessoryType;
self.accessoryView = item.accessoryView;
self.editingAccessoryType = item.editingAccessoryType;
self.editingAccessoryView = item.editingAccessoryView;
self.textLabel.textAlignment = item.textAlignment;
if (self.selectionStyle != UITableViewCellSelectionStyleNone)
self.selectionStyle = item.selectionStyle;
Expand Down Expand Up @@ -250,7 +252,7 @@ - (NSIndexPath *)indexPathForPreviousResponder
- (NSIndexPath *)indexPathForNextResponderInSectionIndex:(NSUInteger)sectionIndex
{
RETableViewSection *section = [self.tableViewManager.sections objectAtIndex:sectionIndex];
NSUInteger indexInSection = [section isEqual:self.section] ? [section.items indexOfObject:self.item] : -1;
NSUInteger indexInSection = [section isEqual:self.section] ? [section.items indexOfObject:self.item] : -2 - section.items.count;
for (NSInteger i = indexInSection + 1; i < section.items.count; i++) {
RETableViewItem *item = [section.items objectAtIndex:i];
if ([item isKindOfClass:[RETableViewItem class]]) {
Expand Down
3 changes: 3 additions & 0 deletions RETableViewManager/RETableViewItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@
@property (assign, readwrite, nonatomic) UITableViewCellStyle style;
@property (assign, readwrite, nonatomic) UITableViewCellSelectionStyle selectionStyle;
@property (assign, readwrite, nonatomic) UITableViewCellAccessoryType accessoryType;
@property (assign, readwrite, nonatomic) UITableViewCellAccessoryType editingAccessoryType;
@property (assign, readwrite, nonatomic) UITableViewCellEditingStyle editingStyle;
@property (strong, readwrite, nonatomic) UIView *accessoryView;
@property (strong, readwrite, nonatomic) UIView *editingAccessoryView;
@property (assign, readwrite, nonatomic) BOOL enabled;
@property (copy, readwrite, nonatomic) void (^selectionHandler)(id item);
@property (copy, readwrite, nonatomic) void (^accessoryButtonTapHandler)(id item);
@property (copy, readwrite, nonatomic) void (^editingAccessoryButtonTapHandler)(id item);
@property (copy, readwrite, nonatomic) void (^insertionHandler)(id item);
@property (copy, readwrite, nonatomic) void (^deletionHandler)(id item);
@property (copy, readwrite, nonatomic) void (^deletionHandlerWithCompletion)(id item, void (^)(void));
Expand Down
19 changes: 15 additions & 4 deletions RETableViewManager/RETableViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -563,10 +563,21 @@ - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexP
{
RETableViewSection *section = [self.mutableSections objectAtIndex:indexPath.section];
id item = [section.items objectAtIndex:indexPath.row];
if ([item respondsToSelector:@selector(setAccessoryButtonTapHandler:)]) {
RETableViewItem *actionItem = (RETableViewItem *)item;
if (actionItem.accessoryButtonTapHandler)
actionItem.accessoryButtonTapHandler(item);

if (self.tableView.editing) {

if ([item respondsToSelector:@selector(setEditingAccessoryButtonTapHandler:)]) {
RETableViewItem *actionItem = (RETableViewItem *)item;
if (actionItem.editingAccessoryButtonTapHandler)
actionItem.editingAccessoryButtonTapHandler(item);
}

} else {
if ([item respondsToSelector:@selector(setAccessoryButtonTapHandler:)]) {
RETableViewItem *actionItem = (RETableViewItem *)item;
if (actionItem.accessoryButtonTapHandler)
actionItem.accessoryButtonTapHandler(item);
}
}

// Forward to UITableView delegate
Expand Down