ios7下uisearchbar会消失


在ios下的一个tableview下我添加了下面代码:


 //创建搜索栏和搜索显示控制器
    _searchBar = [[UISearchBar  alloc] initWithFrame:CGRectMake(0, 0, BOUNDSSIZE.width, 44)];
    _searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
    _searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;
    _searchBar.keyboardType = UIKeyboardTypeAlphabet;
    _searchBar.placeholder = [NSString stringWithCString:"搜索(请输入项目关键字)                        "  encoding: NSUTF8StringEncoding];

    self.tableView.tableHeaderView = _searchBar;

    _searchDc=[[UISearchDisplayController alloc] initWithSearchBar:_searchBar contentsController:self];
    _searchDc.searchResultsDataSource=self;
    _searchDc.searchResultsDelegate=self;

就添加了一个searchBar在tableview上面,可是我对着tableview或者那个searchBar点了几次之后它会突然消失,怎么回事

ios objective-c iphone ios7

我是老司机 11 years ago

Your Answer