uisearchDisplayController放在tableview裏下拉刷新狀態出現遮擋

代碼如下

- (void)viewDidLoad {
    [super viewDidLoad];

    UISearchBar * searchBar =[[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
    self.tableView.tableHeaderView=searchBar;

    self.searchController =[[UISearchDisplayController alloc]initWithSearchBar:searchBar contentsController:self];

    //
    //(refreshing)
    //
    [self.tableView setContentInset:UIEdgeInsetsMake(128, 0, 0, 0)];
}

問題如圖:


問題:searchBar的視圖中clipsToBounds 爲yes

解決方法:自定義searchbar,重寫layoutSubviews方法,把searchbar的所有subview的clipsToBounds重置爲no

-(void)layoutSubviews{
    [super layoutSubviews];
    for (UIView * view in self.subviews) {
        view.clipsToBounds=NO;
    }
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章