Merge pull request #173 from unixo/master

RETableViewOptionsController current selection
This commit is contained in:
Roman Efimov
2014-07-29 12:55:52 -07:00
3 changed files with 8 additions and 8 deletions

View File

@@ -33,10 +33,10 @@
@property (strong, readonly, nonatomic) RETableViewManager *tableViewManager;
@property (strong, readonly, nonatomic) RETableViewSection *mainSection;
@property (assign, readwrite, nonatomic) BOOL multipleChoice;
@property (copy, readwrite, nonatomic) void (^completionHandler)(void);
@property (copy, readwrite, nonatomic) void (^completionHandler)(RETableViewItem *item);
@property (strong, readwrite, nonatomic) RETableViewCellStyle *style;
@property (weak, readwrite, nonatomic) id<RETableViewManagerDelegate> delegate;
- (id)initWithItem:(RETableViewItem *)item options:(NSArray *)options multipleChoice:(BOOL)multipleChoice completionHandler:(void(^)(void))completionHandler;
- (id)initWithItem:(RETableViewItem *)item options:(NSArray *)options multipleChoice:(BOOL)multipleChoice completionHandler:(void(^)(RETableViewItem *item))completionHandler;
@end

View File

@@ -35,7 +35,7 @@
@implementation RETableViewOptionsController
- (id)initWithItem:(RETableViewItem *)item options:(NSArray *)options multipleChoice:(BOOL)multipleChoice completionHandler:(void(^)(void))completionHandler
- (id)initWithItem:(RETableViewItem *)item options:(NSArray *)options multipleChoice:(BOOL)multipleChoice completionHandler:(void(^)(RETableViewItem *item))completionHandler
{
self = [super initWithStyle:UITableViewStyleGrouped];
if (!self)
@@ -102,7 +102,7 @@
RERadioItem * __weak item = (RERadioItem *)weakSelf.item;
item.value = selectedItem.title;
if (weakSelf.completionHandler)
weakSelf.completionHandler();
weakSelf.completionHandler(selectedItem);
} else { // Multiple choice item
REMultipleChoiceItem * __weak item = (REMultipleChoiceItem *)weakSelf.item;
[weakSelf.tableView deselectRowAtIndexPath:selectedItem.indexPath animated:YES];
@@ -125,7 +125,7 @@
refreshItems();
}
if (weakSelf.completionHandler)
weakSelf.completionHandler();
weakSelf.completionHandler(selectedItem);
}
}]];
};

View File

@@ -141,7 +141,7 @@
// Present options controller
//
RETableViewOptionsController *optionsController = [[RETableViewOptionsController alloc] initWithItem:item options:options multipleChoice:NO completionHandler:^{
RETableViewOptionsController *optionsController = [[RETableViewOptionsController alloc] initWithItem:item options:options multipleChoice:NO completionHandler:^(RETableViewItem *selectedItem){
[weakSelf.navigationController popViewControllerAnimated:YES];
[item reloadRowWithAnimation:UITableViewRowAnimationNone]; // same as [weakSelf.tableView reloadRowsAtIndexPaths:@[item.indexPath] withRowAnimation:UITableViewRowAnimationNone];
@@ -172,9 +172,9 @@
// Present options controller
//
RETableViewOptionsController *optionsController = [[RETableViewOptionsController alloc] initWithItem:item options:options multipleChoice:YES completionHandler:^{
RETableViewOptionsController *optionsController = [[RETableViewOptionsController alloc] initWithItem:item options:options multipleChoice:YES completionHandler:^(RETableViewItem *selectedItem){
[item reloadRowWithAnimation:UITableViewRowAnimationNone];
NSLog(@"%@", item.value);
NSLog(@"parent: %@, child: %@", item.value, selectedItem.title);
}];
// Adjust styles