mirror of
https://github.com/zhigang1992/RETableViewManager.git
synced 2026-01-12 22:51:51 +08:00
Merge pull request #173 from unixo/master
RETableViewOptionsController current selection
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}]];
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user