I want to push a UIViewController
into the UINavigationController
when I click over a UISearchBar
, such that the keyboard does not appear, just open the new view, and when I come back, show some string in the UISearchBar
.
Thank you
yoursearchBar.delegate = yourDelegateObject;
Then inside your yourDelegateObject
Class, have this UISearchBar
delegate method
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar{
// Here write the code to push to new view controller
return NO;
}
You could place a custom UIButton
over your UISearchBar
and push the new UIViewController
on button press OR you could set your UIViewController
as the UISearchBar
delegate and implement searchBarShouldBeginEditing , return NO to prevent input and push the UIViewController
from this "delegate" method. You will also probably need to implement some form of delegation to have your string on coming back to the pushing UIViewController
in order to populate it in the UISearchBar
You can use your custom UIView
instead of the standard keyboard. Just set in code:
UISearchbar *mySearchbar = [[UISearchbar alloc] init];
mySearchbar.inputView = myInputView;
If you now tap on the searchbar your myCustomView
will appear on the bottom of the window (where the keyboard is located usually).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.