在选项中,粘贴和定义是确定的,但是当我单击副本或剪切时,它将崩溃。我试图删除除搜索栏以外的所有代码,但它也无法正常工作。我尝试覆盖textfield方法,但搜索栏 subview 不包含UITextField
这是我的代码
_searchBar = [[UISearchBar alloc] initWithFrame:self.topBar.bounds];
[_searchBar setPlaceholder:LS(@"Search", @"")];
[_searchBar setDelegate:self];
_searchController = [[UISearchDisplayController alloc] initWithSearchBar:_searchBar contentsController:self];
_searchController.delegate = self;
_searchController.searchResultsDataSource = self;
_searchController.searchResultsDelegate = self;
if( _scopeButtonTitles ) {
_searchBar.scopeButtonTitles = _scopeButtonTitles;
_searchBar.showsScopeBar = YES;
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[_searchBar resignFirstResponder];
}
#pragma mark - UISearchBarDelegate
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
_searchResultsAvailable = NO;
}
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
self.loadingTitle = [NSString stringWithFormat:@"%@ %@%@",LS(@"Searching", @""),self.title?self.title:@"",@"..."];
_searchResultsAvailable = YES;
}
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
_searchResultsAvailable = NO;
}
最佳答案
我已经多次启动该错误,然后在我的应用中发现了错误。
它只需要重写searchBar的复制和剪切方法。
在我重写方法后,错误消失了
关于ios - 单击搜索栏文本字段中的复制或剪切选项时,应用崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28472879/