Skip to content

A powerful control to select and search from the list like dropdown in android

Notifications You must be signed in to change notification settings

rushisangani/RSSelectionViewController

Repository files navigation

RSSelectionViewController

A powerful control to select items from the list like dropdown in Android. Save time by avoding boilerplate code in your project for search and selection screen.

RSSelectionViewController can be used as a ViewController in which user can select single/multiple items, search through the list and get selected item as string to display results.

Alt text Alt text

Alt text Alt text

Features

  • Present/Push/PopOver RSSelectionViewController as per need.
  • Enable multiple selection using single property allowMultipleSelection.
  • Enable search funtionality using single property allowSearch.
  • Allow empty selection when you don't want to select anything by using single property allowEmptySelection.
  • Customizable NavigationBar, and Buttons color etc.
  • Customizable SarchBar place holder, color etc.
  • Get selected items as a string to display using delegate method.

How To Use

Single Selection

RSSelectionViewController *selectionController = [[RSSelectionViewController alloc] initWithNibName:NSStringFromClass([RSSelectionViewController class]) bundle:nil];

/* pass array as a dataSource, array of selected objects if any and identifier if required */
[selectionController setDataArray:dataArray selectedObjects:selectedArray andDelegate:self forIdentifier:identifier];

/* set title if required */
selectionController.navigationTitle = @"Select Name";

[self.navigationController pushViewController:selectionController animated:YES];

Multiple Selection

RSSelectionViewController *selectionController = [[RSSelectionViewController alloc] initWithNibName:NSStringFromClass([RSSelectionViewController class]) bundle:nil];

/* pass array as a dataSource, array of selected objects if any and identifier if required */
[selectionController setDataArray:dataArray selectedObjects:selectedArray andDelegate:self forIdentifier:identifier];

/* pass keyname to display row title if dataArray contains dictionary */
selectionController.dataAccessKey = @"key_name";

/* enable multiple selection */
selectionController.allowMultipleSelection = YES;

/* set custom seperator */
selectionController.seperator = @" |";

[self.navigationController pushViewController:selectionController animated:YES];

Selection with Search

RSSelectionViewController *selectionController = [[RSSelectionViewController alloc] initWithNibName:NSStringFromClass([RSSelectionViewController class]) bundle:nil];

/* pass array as a dataSource, array of selected objects if any and identifier if required */
[selectionController setDataArray:dataArray selectedObjects:selectedArray andDelegate:self forIdentifier:identifier];

/* set title if required */
selectionController.navigationTitle = @"Select Name";

/* enable search */
selectionController.allowSearch = YES;

/* set searchBar placeholder if required */
selectionController.searchPlaceHolder = @"Search Name";

[self.navigationController pushViewController:selectionController animated:YES];

Get Selected Data using delegate method

#pragma mark- RSSelectionDelegate methods

- (void)getSelectedObjects:(NSArray *)selectedObjects andConcatenatedString:(NSString *)string forIdentifier:(NSString *)identifier {
    
    /* replace previous selected objects with new objects */
    [selectedArray setArray:selectedObjects];
    
    /* display selected objects as a concatenated string */
    self.label.text = string;
}

- (void)getSearchedText:(NSString *)searchedText forIdentifier:(NSString *)identifier {
    // get text typed in searchBar 
}

License

RSSelectionViewController is released under the MIT license. See LICENSE for details.

About

A powerful control to select and search from the list like dropdown in android

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published