![](/img/trans.png)
[英]Perform action on UISearchBar when Keyboard is down and the x has been tapped
[英]UISearchBar not showing keyboard when tapped
我以編程方式在視圖中添加了一個UISearchBar,做了一些初始設置。 但是,當我點擊搜索欄時,鍵盤沒有顯示出來。 我在這個網站上查了一些問題,似乎沒有人對我有用。
這是我用來設置搜索欄的代碼片段
self.searchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(origin.x,origin.y,width,height)];
self.searchBar.searchBarStyle = UISearchBarStyleDefault;
self.searchBar.translucent = YES;
self.searchBar.barTintColor = [UIColor whiteColor];
...
[self.searchBar setDelegate:self];
[self.view addSubView:self.searchBar];
有什么建議來修復這個? 謝謝!
如果您使用的是Xcode 6.0.1,則可能是您的硬件鍵盤正在接管模擬器鍵盤。 運行模擬器時,請確保未選中此選項。 當您點按搜索欄時,這應觸發模擬器鍵盤:
]
另外,這篇文章解釋了如何回到Xcode 5.1.1中鍵盤的行為:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.