相关疑难解决方法(0)

更改UISearchBar TextField的大小?

我有一个带有索引的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)

有任何想法吗?

iphone search uitableview

30
推荐指数
6
解决办法
5万
查看次数

标签 统计

iphone ×1

search ×1

uitableview ×1