Make iPhone status bar disappear when displaying a modal view?

前端 未结 2 1702
轮回少年
轮回少年 2021-01-12 19:59

I want to display a modal view, and want it to cover the iPhone\'s status bar.

I tried setting the modal view controller\'s wantsFullScreenLayout property to YES; I

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-12 20:13

    Joining the discusion late, but I think I can save others some trouble.

    I have a VC several pushes into a NavController (let's call that VC the PARENT). Now I want to display a modal screen (the CHILD) with the nav bar AND status bar hidden. After much experimentation, I know this works...

    1) Because I present the CHILD VC by calling presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated in the PARENT, the nav bar is not involved anymore (no need to hide it).

    2) The view in the CHILD VC nib is sized to 320x480.

    3) The CHILD VC sets self.wantsFullScreenLayout = YES; in viewDidLoad

    4) just before presenting the CHILD, hide the status bar with [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:YES];

    5) dismiss the CHILD VC using a delegate protocol methods in the PARENT, and call [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:YES]; before dismissModalViewControllerAnimated:YES] to make sure the nav bar is drawn in the correct location

    Hope this helps.

提交回复
热议问题