当我在搜索栏文本字段中单击复制或剪切选项时,应用程序崩溃

时间:2015-02-12 08:44:00

标签: ios crash textfield searchbar

在选项中,粘贴和定义是正常的,但是当我单击副本或剪切它将崩溃。我试图删除除搜索栏以外的所有代码,但它也没有工作。我试图覆盖textfield方法,但搜索栏子视图不包含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;
}

1 个答案:

答案 0 :(得分:-1)

我多次推出该错误,并在我的应用中发现错误。 它只需要重写searchBar的复制和剪切方法。 在我重写方法之后,bug已经消失了