nicklockwood / iCarousel

A simple, highly customisable, data-driven 3D carousel for iOS and Mac OS
http://www.charcoaldesign.co.uk/source/cocoa#icarousel
Other
12k stars 2.58k forks source link

Search within iCarousel #413

Open vividcode opened 10 years ago

vividcode commented 10 years ago

Is there any built-in mechanism in iCarousel for searching its views, filtering them by content? Like this - https://developer.apple.com/library/ios/documentation/uikit/reference/UISearchDisplayController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40008225-CH1-SW4?

Many thanks for an awesome library!

leehericks commented 10 years ago

No, you can do this easily yourself.

Usually your carousel is backed by some data. Provide your our search bar and use the UISearchBarDelegate methods to filter your data and then ask the carousel to reload.

For example, you may create a property NSArray *filteredDataItems and in the carousel data source methods check.

if (self.filteredDataItems) {/use filtered/} else {/use regular/}

leehericks commented 10 years ago

Conversely, on iPad you can use a UISearchBar and UISearchDisplayController (which is displayed in a popover), and when receiving notification that a result row was selected, scroll to that item in the carousel.