ios - 切换标签时 UITabBarController 变黑

标签 ios objective-c uinavigationcontroller uitabbarcontroller uisearchcontroller

我嵌入了一个 UITabBarController 在 UINavigationController 中。 UITabBarController 包含 3 个不同的选项卡,导致 3 个不同的 UIViewControllers 显示 UITableView。我通过 Storyboard 实现了所有这些。在第一个 UIViewController 中,我实现了 UISearchController 以编程方式运行的 UITableView。 当我搜索特定单元格然后切换选项卡时, View 变为黑色。
我相信这个问题与 SearchController 有一些关系,因为在包含 SearchController 之前,我没有任何问题。

我在这里解决了其他几个问题,但没有一个可以解决我的问题。

编辑:

下面是我与 SearchController 相关的代码。

@接口(interface)

@property (nonatomic, strong) UISearchController *searchController;
@property BOOL searchControllerWasActive;
@property BOOL searchControllerSearchFieldWasFirstResponder;

@实现

viewDidAppear()
self.searchController = [[UISearchController alloc]initWithSearchResultsController:nil];
self.searchController.searchResultsUpdater = self;
[self.searchController.searchBar sizeToFit];
self.tblContactsTable.tableHeaderView = self.searchController.searchBar;

self.searchController.delegate = self;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.searchBar.delegate = self;

self.definesPresentationContext = YES;

- (void)updateSearchResultsForSearchController:(UISearchController *)searchController
//reloads table view according to what is searched.

-(void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
self.searchController.searchBar.showsCancelButton = NO;

最佳答案

UITabBarController 应该是 Storyboard/代码中窗口上最顶层的元素,您可以将导航 Controller 和 View Controller 添加到 UITabBarController View Controller 。
https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UITabBarController_Class/index.html

关于ios - 切换标签时 UITabBarController 变黑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35980266/

相关文章:

ios - Localizable.strings 的字符编码,由 genstrings 生成

ios - iPhone 的 Urban Airship 推送通知 : SSL Problem

Objective-C 静态内联 NSString 数组

ios - 调用 [UIColor colorWithRed :green:blue:alpha:] causing terrible crash

ios - 7段显示OCR

Objective-C (iOS) : prepareForSegue won't pass my data into destination VC

ios - (Swift) 在主 UINavigationController 内嵌套的 UINavigationController 和 UITabController 之间切换

ios - UINavigationController pushViewController 生命周期

ios - [self.navigationController pushViewController :ngView animated:YES]; not working

objective-c - UITableView 以编程方式选择选项