/JKPickerViewController

Ready to use PickerViewController

Primary LanguageObjective-CMIT LicenseMIT

JKPickerViewController

Ready to use PickerViewController

Loading data from a array.

NSArray *simpleDataArray = @[@"Jan", @"Feb", @"Mar", @"Apr", @"May"];

JKPickerViewController *pickerVC = [JKPickerViewController picker];
[pickerVC setDataSource:@[simpleDataArray]];
[pickerVC showPickerInViewController:self
               withSelectionHandler:^(JKPickerViewController *pickerVC, id selectedData) {
                   if (selectedData) {
                       NSLog(@"Selected Data = %@", selectedData);
                   }
               }];

Loading data from array of dictionary.

NSArray *arrayOfDic = @[@{@"id": @"1", @"month": @"Jan"},
                        @{@"id": @"2", @"month": @"Feb"},
                        @{@"id": @"3", @"month": @"Mar"},
                        @{@"id": @"4", @"month": @"Apr"},
                        @{@"id": @"5", @"month": @"May"}];

JKPickerViewController *pickerVC = [JKPickerViewController picker];
[pickerVC setDataSource:@[arrayOfDic]];
[pickerVC setTitleKeyPath:@"month"];
[pickerVC showPickerInViewController:self
               withSelectionHandler:^(JKPickerViewController *pickerVC, id selectedData) {
                   if (selectedData) {
                       NSLog(@"Selected Data = %@", selectedData);
                   }
               }];

Preselecting a value

For array

[pickerVC setSelectedRowData:@[@"Apr"]];

For array of dictionary

[pickerVC setSelectedRowData:@[@{@"id": @"4", @"month": @"Apr"}]];