现在的位置: 首页 > 综合 > 正文

DataTableDelegate 使用方法

2018年02月02日 ⁄ 综合 ⁄ 共 943字 ⁄ 字号 评论关闭
@property(nonatomic, strong) UISearchDisplayController *strongSearchDisplayController;
@property(nonatomic, strong, readwrite) UISearchBar *searchBar;

-(void)InitTableView
{
    // Uncomment the following line to preserve selection between presentations.
    self.delegate = [[DataTableDelegate alloc]init];
    self.delegate.delegate = self;
    self.delegate.parentTableView = self.tableView;
    self.tableView.dataSource = self.delegate;
    self.tableView.delegate = self.delegate;
    
    self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectZero];
    self.searchBar.placeholder = @"Search";
    self.searchBar.delegate = self.delegate;
    
    [self.searchBar sizeToFit];
    
    self.strongSearchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:self.searchBar contentsController:self];
    self.searchDisplayController.searchResultsDataSource = self.delegate;
    self.searchDisplayController.searchResultsDelegate = self.delegate;
    self.searchDisplayController.delegate = self.delegate;
    
    self.tableView.tableHeaderView = self.searchBar;
}

抱歉!评论已关闭.