Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios tableview标题中的UISearchController搜索栏留有状态栏大小的间隙_Ios_Objective C_Uitableview - Fatal编程技术网

Ios tableview标题中的UISearchController搜索栏留有状态栏大小的间隙

Ios tableview标题中的UISearchController搜索栏留有状态栏大小的间隙,ios,objective-c,uitableview,Ios,Objective C,Uitableview,Im使用带有tableView的UIViewController。我已经设置了一个searchcontroller,并将搜索栏嵌入到tableview标题中。当我搜索时,它会在tableview和上面的uiview之间留下一个状态栏大小的间隙。我意识到还有很多其他的问题,但是没有一个解决了这个问题 以下是设置搜索栏的代码: self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil

Im使用带有tableView的UIViewController。我已经设置了一个searchcontroller,并将搜索栏嵌入到tableview标题中。当我搜索时,它会在tableview和上面的uiview之间留下一个状态栏大小的间隙。我意识到还有很多其他的问题,但是没有一个解决了这个问题

以下是设置搜索栏的代码:

self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchController.searchResultsUpdater = self;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.hidesNavigationBarDuringPresentation = YES;
self.searchController.searchBar.delegate = self;
self.searchController.searchBar.backgroundImage = [UIImage new];
self.searchController.searchBar.backgroundColor = kBlueNavBarColor;
self.searchController.searchBar.tintColor = [UIColor whiteColor];

self.tableView.tableHeaderView = self.searchController.searchBar;
self.definesPresentationContext = YES;

我在以模式显示
UIViewController
时也遇到类似问题。导航栏升得太高了。我调整了导航栏的大小,使它宽了一点。让我知道这是否有帮助。这个问题始于iOS 7。您可能不需要检查版本

float currentVersion = 7.0;
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= currentVersion) {
        // iOS 7
        self.navBar.frame = CGRectMake(self.navBar.frame.origin.x, self.navBar.frame.origin.y, self.navBar.frame.size.width, 64);
    }


取消选中“调整滚动视图插图”

我通过将用于固定分段控制器的视图的“顶部”自动布局定位点从“超级视图”更改为“顶部布局指南”,对其进行了修复。这将间隙向上移动到状态栏所在的位置,并将整个视图的背景颜色更改为与导航栏相同的蓝色,使其无缝。

当您调整导航栏的大小时,会发生什么情况?灰色仍然略低一点?我找到了答案,请参阅我的答案。谢谢