我有一个带有索引的UITableView; 我想为它添加一个UISearchBar,但索引与"x"重叠以清除搜索.我已经注意到在Contacts应用程序中,UISearchBar中的文本字段被调整大小以适应这一点,但我无法弄清楚如何在我自己的应用程序中执行此操作.
我在viewDidLoad中尝试了以下内容,但它似乎不起作用.
UITextField * textField = (UITextField *)[[self.search subviews] objectAtIndex:0];
CGRect r = textField.frame;
[textField setFrame:CGRectMake(r.origin.x, r.origin.y, r.size.height, r.size.width-30)];
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我有UISearchBar(带UISearchDisplayController)作为标题视图UINavigationBar.导航栏中搜索栏的两侧还有两个按钮.
单击时UISearchBar,它会变宽并覆盖右侧的按钮.
如何阻止它变宽?
事情尝试但没有奏效 - >
[searchBar setNeedsLayout]-searchBarTextDidBeginEditingauto-resizing mask选择IB编辑:没提,但这是在iPhone上(因为我们可以放在searchbariPad的工具栏中..)