gpt4 book ai didi

ipad - uisearchbar 未显示键盘

转载 作者:行者123 更新时间:2023-11-29 13:51:02 25 4
gpt4 key购买 nike

我有一个 UISearchBar也就是说,即使它是第一响应者,也不会显示键盘。我可以使用笔记本电脑的键盘在搜索栏中开始输入,并且可以看到我在搜索栏中输入的内容,但模拟器和实际 iPad 上的键盘不会出现。它在 iOS 3.2 下运行良好,但在今天早上更新到 iOS 4.2 后停止运行。下面是相关代码:



<pre>// Text Field that when touched will fire a search view that contains the search bar
- (void)textFieldDidBeginEditing:(UITextField *)textField {
[textField resignFirstResponder];

UIViewController *detailViewController = nil;

ImplementedSearchViewController *searchController =
[[ImplementedSearchViewController alloc] initWithNibName:@"ImplementedSearchView" bundle:nil];
...
detailViewController = searchController;

MyAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
UINavigationController *nav = (UINavigationController *)
[delegate.splitViewController.viewControllers objectAtIndex: 0];
NSArray *viewControllers = [NSArray arrayWithObjects:nav,
detailViewController, nil];
self.splitViewController.viewControllers = viewControllers;

HomeViewController *hHomeController = [nav.viewControllers objectAtIndex:0];

// Dismiss the popover if it's present.
if (homeController.popoverController != nil) {
[homeController.popoverController dismissPopoverAnimated:YES];
}

// Configure the new view controller's popover button
(after the view has been displayed and its toolbar/navigation bar has been created).
if (homeController.rootPopoverButtonItem != nil) {
[detailViewController
showRootPopoverButtonItem:homeController.rootPopoverButtonItem];
}

[detailViewController release];
}
</pre>



<pre>// Inside the viewDidLoad of the search view
- (void)viewDidLoad {
self.table.frame = CGRectMake(table.frame.origin.x, table.frame.origin.y, table.frame.size.width, 680);
self.table.backgroundColor = [UIColor colorWithRed:239/255.0 green:244/255.0 blue:255/255.0 alpha:1.0];
// searchBar is a UISearchBar
[self.searchBar becomeFirstResponder];
}
</pre>

viewDidLoad中的ui搜索栏不是 nil .

对此有什么想法吗?

谢谢,米海

最佳答案

我在 textFieldDidBeginEditing:(UITextField *)textField 委托(delegate)方法上显示搜索栏。

键盘没有显示。因此,首先将 textField 辞去为 firstResponder。即

[textField resignFirstResponder];

然后延迟调用方法

[self performSelector:@selector(callSearchBar) withObject:NULL afterDelay:0.2];

在哪里

-(void)callSearchBar{
[self.searchDisplayController setActive: YES animated: YES];
self.searchDisplayController.searchBar.hidden = NO;
[self.searchDisplayController.searchBar becomeFirstResponder];

有效

关于ipad - uisearchbar 未显示键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4271328/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com