Last active
January 4, 2016 00:09
-
-
Save jdewind/8540164 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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