当应用程序进入后台或再次进入前台时,我想重置我的 UISearch。当 UISearch 中的 tableview 被隐藏时就足够了。
但是当我试图从 AppDelegate.m 中隐藏它时它不起作用。我还记录了 UIElements,还有(null)。
这是我尝试访问它的方法:
- (void)applicationWillEnterForeground:(UIApplication *)application
{
XLog(@"");
/*
Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
*/
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
XLog(@"");
searchViewController = [[SearchViewController alloc] initWithNibName:@"SearchViewController_iPad" bundle:[NSBundle mainBundle]];
} else {
XLog(@"");
searchViewController = [[SearchViewController alloc] initWithNibName:@"SearchViewController_iPhone" bundle:[NSBundle mainBundle]];
}
XLog(@"searchViewController.searchBar.text: %@", searchViewController.searchBar.text);
searchViewController.tableViewSearch.hidden = YES; // is (null)
XLog(@"searchViewController.tableViewSearch: %@", searchViewController.tableViewSearch); // is (null)
}
我怎样才能访问它?我这里有什么问题,还是不允许通过 appdelegate.m 访问其他类的元素?