隐藏键盘iphone sdk?
我有一个 UISearchBar
。我希望用户点击搜索后键盘立即消失...我确实尝试了 resignFirstResponder
但这不起作用。任何帮助将不胜感激,
- (void)viewDidLoad {
[super viewDidLoad];
self.title = NSLocalizedString(@"Songs", @"Search for songs");
NSMutableArray *array = [[NSArray alloc]initWithObjects: @"Book_1", @"Book 2", @"Book _ 4", nil];
self.booksArray = array;
[array release];
search.delegate=self;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
谢谢 TC
I have a UISearchBar
. I want the the keyboard to go away as soon as user hits search...i did try resignFirstResponder
but that didn't work. any help would be appreciated
- (void)viewDidLoad {
[super viewDidLoad];
self.title = NSLocalizedString(@"Songs", @"Search for songs");
NSMutableArray *array = [[NSArray alloc]initWithObjects: @"Book_1", @"Book 2", @"Book _ 4", nil];
self.booksArray = array;
[array release];
search.delegate=self;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
thanks
TC
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请确保以下事项。(我希望您正在谈论键盘的搜索按钮。)
IBOutlet
与其变量search
连接起来。- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
方法与 searchBar 位于相同的viewcontroller
中。searchBarSearchButtonClicked
中,并验证两个实例是否相同,如果不同,则您的search
正在代码中的某个位置重新分配。[searchBar resignFirstResponder];
NSLog(@"isFirstResponder : %d",[searchbar isFirstResponder]); 之后和NSLog(@"Next Responder : %@",[searchBar nextResponder]);
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
当您点击键盘的搜索按钮时正在调用方法?确保您的
后面没有添加键盘
可能是无意的。也请通过xib检查。responder
(例如textField
、textView
或其他searchBar
) >searchBar谢谢,
Please make sure of following things.(I hope you are talking about search Button of keyboard.)
IBOutlet
of searchBar with its variablesearch
.- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
method is in sameviewcontroller
as searchBar is in.searchBarSearchButtonClicked
and verify that both instances are same if not then you aresearch
is getting reassigned somewhere in code.[searchBar resignFirstResponder];
NSLog(@"isFirstResponder : %d",[searchbar isFirstResponder]); andNSLog(@"Next Responder : %@",[searchBar nextResponder]);
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
method is being called when you tap search Button of keyboard? Make sure there are no keyboard
responder
(liketextField
,textView
or othersearchBar
) is added behind yoursearchBar
may be unintentionally. Please check it through xib also.Thanks,
它应该通过在委托对象上实现响应方法来工作:
参考:http://www.iphonedevsdk.com/forum/iphone-sdk-development/7148-problem-uisearchbar-navigation-controller.html#post59467
It should work by implementing the respond methods at the delegate object:
Reference: http://www.iphonedevsdk.com/forum/iphone-sdk-development/7148-problem-uisearchbar-navigation-controller.html#post59467