Skip to content

Instantly share code, notes, and snippets.

@jdewind
Last active January 4, 2016 00:09
Show Gist options
  • Save jdewind/8540164 to your computer and use it in GitHub Desktop.
Save jdewind/8540164 to your computer and use it in GitHub Desktop.
class MyViewController < UIViewController
def viewDidLoad
@search_bar = UISearchBar.alloc.initWithFrame CGRectZero
self.navigationController.rac_liftSelector "setNavigationBarHidden:animated:", withSignalsFromArray: [@search_bar.rac_editing, RACSignal.return(true)]
# Add search bar to table view, etc.
end
end
class UISearchBar
def rac_editing
self.delegate = self
protocol = NSProtocolFromString("UISearchBarDelegate")
@editing ||= RACSignal.merge([
rac_signalForSelector("searchBarTextDidBeginEditing:", fromProtocol: protocol).mapReplace(true),
rac_signalForSelector("searchBarTextDidEndEditing:", fromProtocol: protocol).mapReplace(false)]
).startWith(false).takeUntil(rac_willDeallocSignal)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment