CocoaPods trunk is moving to be read-only. Read more on the blog, there are 14 months to go.
| TestsTested | ✗ |
| LangLanguage | Obj-CObjective C |
| License | MIT |
| ReleasedLast Release | Dec 2014 |
Maintained by Liam Nichols.
MOOSelectableListViewController is a UITableViewControler subclass that offers easy managment of selecting an item from within a specified list.
A basic example can be be found below:
//Build a list of dummy values, each item should be an NSDictionary with the values 'title' and 'value'
NSMutableArray *items = [NSMutableArray new];
for (int i = 0; i < 10; i ++)
[items addObject:@{ @"title" : @"Item Title", @"value" : @(i) }];
//initalise the view controller (using basic settings), see readme or header for more advanced options
MOOSelectableListViewController *rootViewController = [[MOOSelectableListViewController alloc] initWithItems:items changedBlock:^(id title, id value) {
NSLog(@"Selected item: %@ (%@)",title, value);
}];
[self presentViewController:rootViewController animated:YES completion:nil];
The array of items passed to the view controller must contain NSDictionary objects what contain title and value keys. title should be a NSString and value can be any NSObject but it must be unique.
- (id)initWithItems:(NSArray *)items changedBlock:(didSelectItemBlock)block selectedItem:(id)selected cellClass:(Class)cellClass tableViewStyle:(UITableViewStyle)style;
You can also specify the following information for more advanced usage:
UITableViewStyle (defaults to UITableViewStylePlain)UITableViewCell class (must be a subclass of MOOSelectableListCell)isEqual: to the selectedItem will be marked as selectedThe MOOSelectableListCell is a basic subclass of UITableViewCell and subclassing it is very easy.
Your custom subclass should implement the updateCellWithTitle:value:selected: method. This is called every time tableView:cellForRowAtIndexPath: is called.
the selected boolean is used to specify if the [value isEqualTo:selectedValue].
This property is used to specify if the selectedValue property should be updated. It is defaulted to YES but when set to NO the cells will not reload to display the selection, only the didSelectItemBlock will be called to indicate that an item has been selected.
If you specify a selectedItem then this property should be left set to YES.
iOS 5.0 + using ARC
See LICENSE