我通过包含使UINavigationController成为另一个视图控制器的子节点.一切正常,除了在打开呼叫状态栏打开时启动应用程序时出现的奇怪问题,然后在应用程序UI在屏幕上后将其切换回OFF.在状态栏的位置出现了一个奇怪的黑色间隙.
考虑下面的自包含示例应用程序:
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong,nonatomic) UIWindow *window; @end @implementation AppDelegate - (BOOL)application:(UIApplication *)app didFinishLaunchingWithOptions:(NSDictionary *)opt { // Content UILabel * aLbl = [[UILabel alloc] initWithFrame:CGRectMake(20,100,200,40)]; aLbl.text = @"In-call status bar issue"; UIViewController * aContent = [[UIViewController alloc] init]; aContent.title = @"Title"; aContent.view.backgroundColor = UIColor.whiteColor; [aContent.view addSubview:aLbl]; UINavigationController * aNav = [[UINavigationController alloc] initWithRootViewController:aContent]; // Parentmost view controller containing the navigation view controller UIViewController * aParent = [[UIViewController alloc] init]; [aParent.view addSubview:aNav.view]; [aParent addChildViewController:aNav]; [aNav didMoveToParentViewController:aParent]; self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]; self.window.rootViewController = aParent; [self.window makeKeyAndVisible]; return YES; } @end int main(int argc,char ** argv) { @autoreleasepool { return UIApplicationMain(argc,argv,nil,@"AppDelegate"); } }
重现问题的最简单方法是:
>启动iOS模拟器.
>按⌘Y打开通话中状态栏.状态栏将变为宽绿色.
>手动启动应用程序并等待导航控制器出现.
>再次按⌘Y可关闭通话中状态栏.
UI现在应该如下所示:
有谁知道如何解决这个问题?