From 98f5fbafd63434648c48d08dce949018ca53c59c Mon Sep 17 00:00:00 2001 From: Roman Efimov Date: Thu, 4 Apr 2013 17:31:49 -0500 Subject: [PATCH] Code refactoring --- RETableViewManager/RETableViewCell.m | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/RETableViewManager/RETableViewCell.m b/RETableViewManager/RETableViewCell.m index 80ce2c6..fa3472c 100644 --- a/RETableViewManager/RETableViewCell.m +++ b/RETableViewManager/RETableViewCell.m @@ -158,24 +158,13 @@ - (void)actionBar:(REActionBar *)actionBar navigationControlValueChanged:(UISegmentedControl *)navigationControl { - if (navigationControl.selectedSegmentIndex == 0) { - NSIndexPath *indexPath = [self indexPathForPreviousResponder]; - if (indexPath) { - RETableViewCell *cell = (RETableViewCell *)[self.parentTableView cellForRowAtIndexPath:indexPath]; - if (!cell) - [self.parentTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:NO]; - cell = (RETableViewCell *)[self.parentTableView cellForRowAtIndexPath:indexPath]; - [cell.responder becomeFirstResponder]; - } - } else { - NSIndexPath *indexPath = [self indexPathForNextResponder]; - if (indexPath) { - RETableViewCell *cell = (RETableViewCell *)[self.parentTableView cellForRowAtIndexPath:indexPath]; - if (!cell) - [self.parentTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:NO]; - cell = (RETableViewCell *)[self.parentTableView cellForRowAtIndexPath:indexPath]; - [cell.responder becomeFirstResponder]; - } + NSIndexPath *indexPath = navigationControl.selectedSegmentIndex == 0 ? [self indexPathForPreviousResponder] : [self indexPathForNextResponder]; + if (indexPath) { + RETableViewCell *cell = (RETableViewCell *)[self.parentTableView cellForRowAtIndexPath:indexPath]; + if (!cell) + [self.parentTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:NO]; + cell = (RETableViewCell *)[self.parentTableView cellForRowAtIndexPath:indexPath]; + [cell.responder becomeFirstResponder]; } }