在iOS7上取消后,节标题上的UISearchBar消失

时间:2014-07-20 02:41:38

标签: ios uisearchbar uisearchbardisplaycontrol

我有一个UITableViewController,我想在顶部UISearchBar,所以我使用 viewForHeaderInSection:委托方法,因为当我滚动时,我不想隐藏UISearchBar。问题是(仅限iOS7),当我按下取消按钮时,UISearchBar消失。

这里有一些代码:

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:UITableViewStylePlain];
     if (self) {
        // Custom initialization
        self.filteredListContent = [[NSMutableArray alloc] init];
        mySearchBar = [[UISearchBar alloc] init];
        mySearchBar.delegate = self;
        [mySearchBar setAutocapitalizationType:UITextAutocapitalizationTypeNone];
        [mySearchBar sizeToFit];
        searchDisplayController = [[UISearchDisplayController alloc]initWithSearchBar:mySearchBar contentsController:self];
        [searchDisplayController setDelegate:self];
        [self setSearchDisplayController:searchDisplayController];
        [searchDisplayController setSearchResultsDataSource:self];
        self.tableView.scrollEnabled = YES;
    }

    return self;
}

然后我在mySearchBar委托方法上返回viewForHeaderInSection:

这有什么不对?

0 个答案:

没有答案