ios - UISearchDisplayController 去掉背景中的no results文字
巴扎黑
巴扎黑 2017-04-17 16:32:54
0
3
537
巴扎黑
巴扎黑

reply all(3)
Peter_Zhu

Place the following methods in the UISearchBarDelegate proxy method or UISearchDisplayControllerdelegate proxy method:

1) If you want to change this character and replace it with the string you want, you can try:

  for (UIView *subView in            self.searchDisplayController.searchResultsTableView.subviews) {
    if ([subView isKindOfClass:NSClassFromString(@"UILabel")]) {
        UILabel *label =(UILabel *)subView;
        label.text = @"自定义字符串";
    }
}

2) If you simply want to cover this text, the best method I have ever used is:

  for (UIView *subView in self.searchDisplayController.searchResultsTableView.subviews) {
    if ([subView isKindOfClass:NSClassFromString(@"UILabel")]) {
        UILabel *label =(UILabel *)subView;
     //自定义一个View
        CGFloat ViewWidth = [UIScreen mainScreen].bounds.size.width*0.64;
        CGFloat ViewHeight = ViewWidth*0.75;
        tempNoResultView = [[UIView alloc]init];
        tempNoResultView.size = CGSizeMake(ViewWidth, ViewHeight);
        tempNoResultView.center = CGPointMake([UIScreen mainScreen].bounds.size.width/2, heightToTop);
        tempNoResultView.backgroundColor = [UIColor whiteColor];
        [label addSubview:_tempNoResultView];
    }
}
//相当于遍历出这个label,用一个View把“No Result”遮盖掉。只有这个方法虽然很low但是works well,用其他的方法并不稳定,因为并不建议修改这些东西而且UISearchDisplayController是个坑,这也是为什么后来苹果放弃UISearchDisplayController的原因。
刘奇

It will appear when there is no data, just set a dummy cell.

PHPzhong

When there is no data, set a blank cell. . Deal with it this way. .

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!