我有UISearchController和UITableView.viewDidLoad中的代码是:
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchController.searchResultsUpdater = self;
self.searchController.dimsBackgroundDuringPresentation = YES;
[self.searchController.searchBar sizeToFit];
self.searchController.searchBar.delegate = self;
self.searchController.delegate = self;
self.tableView.tableHeaderView = self.searchController.searchBar;
self.tableView.userInteractionEnabled = YES;
Run Code Online (Sandbox Code Playgroud)
我希望每当我点击搜索栏时都会出现灰色视图,当我开始输入时,灰色视图会消失并显示tableView,这样我就可以点击单元格.这意味着仅当搜索栏为空时才会显示灰色视图(就像邮件和联系人应用程序中的默认搜索行为一样).我试着设置
self.searchController.dimsBackgroundDuringPresentation
Run Code Online (Sandbox Code Playgroud)
在基于searchBar.text的委托方法中
-(void )searchBarTextDidBeginEditing:(UISearchBar *)searchBar
Run Code Online (Sandbox Code Playgroud)
但它不起作用.有任何想法吗?
谢谢,
我正在使用Swift可解码协议来解析我的JSON响应:
{
"ScanCode":"4122001131",
"Name":"PINK",
"attributes":{
"type":"Product",
"url":""
},
"ScanId":"0000000kfbdMA"
}
Run Code Online (Sandbox Code Playgroud)
我遇到一个问题,有时我会用键“ Id”而不是“ ScanId”来获取ScanId值。有办法解决这个问题吗?
谢谢