Mun*_*ndi 5 objective-c uisearchbar ios
我遇到了最怪异的显示错误UISearchBar.
这是我的代码在另一个应用程序中完美运行.(我在代码中创建搜索栏,因为xib文件不可行.)
searchBar = [[UISearchBar alloc] initWithFrame:
CGRectMake(0, 0, self.tableView.frame.size.width, 44)];
searchBar.delegate = self;
searchController = [[UISearchDisplayController alloc]
initWithSearchBar:searchBar contentsController:self];
searchController.delegate = self;
searchController.searchResultsDataSource = self;
searchController.searchResultsDelegate = self;
self.tableView.tableHeaderView = searchBar;
Run Code Online (Sandbox Code Playgroud)
搜索功能等工作正常.但奇怪的是,搜索栏在设备和模拟器上都是这样的:
searchBar.placeholder或searchBar.prompt以@""或nil不移除此"搜索"占位符.(但是,a searchBar.placeholder = @"FooBar";有帮助吗?最紧迫的问题是将文本置于右侧.
ipa*_*son 19
这种行为可能是由于覆盖了(CGRect)editingRectForBounds:(CGRect)bounds或者- (CGRect)textRectForBounds:(CGRect)bounds.您是否更改了UITextField应用中其他类别中的任何一个?这样做的目的可能是为文本字段添加填充(可以用不可见的方式完成leftView).在这种情况下,您的自定义"填充"将应用于UISearchBar文本字段.
这样的类别UITextField也将导致您的应用程序在初始化使用的框架类时崩溃UITextField,例如MFMailComposeViewController,因此出于几个原因这是一个坏主意.
| 归档时间: |
|
| 查看次数: |
3329 次 |
| 最近记录: |