iOS 8 UIModalPresentationPageSheet with status bar hidden - ipad

I am building my app on iOS 8 and getting problem with status bar visibility when UIViewController is presented with modalPresentationStyle = UIModalPresentationPageSheet. I read the documentation that new API true value of "modalPresentationCapturesStatusBarAppearance" used to hide status bar when modal presentation is presented, but I am getting no result with this in this modalPresentationStyle. In my application I am not showing status bar. It was working fine with this style in iOS 7 but when it comes to iOS 8 it is giving problem. Here is my code:
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:viewController];
nav.modalPresentationStyle = UIModalPresentationPageSheet;
nav.modalTransitionStyle=UIModalTransitionStyleCoverVertical;
nav.modalPresentationCapturesStatusBarAppearance = YES; // To hide status bar, doest work with UIModalPresentationPageSheet style
[self.navigationController presentViewController:nav animated:YES completion:NULL];
I am getting like this:
But the desired output is
Please help !!

Use nav.modalPresentationStyle = UIModalPresentationPopover only

Related

Presenting the ViewController in full screen

I am presenting a view controller in a button action as follows,
PromptController *obj = [[[PromptController alloc]initWithNibName:#"PromptController" bundle:nil]autorelease];
UINavigationController *navigation = [[[UINavigationController alloc]initWithRootViewController:obj]autorelease];
[self presentViewController:navigation animated:YES completion:nil];
[AVSession stopRunning];
But it is not presenting on the full screen of the phone. It is presenting as follows
How to present it on the full screen. Any help is really appreciated
In iOS 13 the default presentation style has changed. If you want iOS 12 presentation style, you can change the modalPresentationStyle to .fullScreen.
Swift Version
navigation.modalPresentationStyle = .fullScreen
Objective C
navigation.modalPresentationStyle = UIModalPresentationOverFullScreen;

View Controller status bar is overlapping in new iPhone like ios 8 [duplicate]

This question already has an answer here:
New Xcode version 11.2.1 build app layout problem [duplicate]
(1 answer)
Closed 3 years ago.
View Controller status bar is overlapping in new iPhone like ios 8 When it's redirecting to another view controller , existing view screen status bar is displaying partially. I am using this code to redirect
SecondView *view = [[SecondView alloc] initWithNibName:nil bundle:nil];
[self presentViewController:view animated:YES completion:NULL];
This is not bug of status bar, this is feature of iOS 13, If you don't want this than you can set modalPresentationStyle to fullscreen. Like,
SecondView *view = [[SecondView alloc] initWithNibName:nil bundle:nil];
view.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:view animated:YES completion:NULL];

How do I remove navigation tab added by SWRevealViewController?

I am using am SWRevealViewController in my iOS 8.2 app. It works perfectly fine, but when my view displays though it a frosted navigation bar hangs around at the top of the screen, under the status bar. It is covering my background image, and I haven't found an easy way to remove it.
mainView = [[ViewController alloc] init];
sideMenu = [[MenuController alloc] init];
UINavigationController * frontViewController = [[UINavigationController alloc] initWithRootViewController:mainView];
UINavigationController * rearViewController = [[UINavigationController alloc] initWithRootViewController:sideMenu];
revealController = [[SWRevealViewController alloc] initWithRearViewController:rearViewController frontViewController:frontViewController];
revealController.delegate = mainView;
I searched through the SWRevealViewController code and didn't find anything obviously related to it. I tried commenting out suspicious sections of code and viewing the result. I hid the status bar. Nothing touched it.
I have tried a few things...
[frontViewController.navigationController setNavigationBarHidden:YES];
frontViewController.navigationController.navigationBar.frame = CGRectZero;
[frontViewController.navigationController.navigationBar setHidden:YES];
[revealController.navigationController setNavigationBarHidden:YES];
revealController.navigationController.navigationBar.frame = CGRectZero;
[revealController.navigationController.navigationBar setHidden:YES];
[revealController.navigationController.navigationBar setBounds:CGRectZero];
...to no effect.
As your front view is mainView you will be using
[mainView.navigationController setNavigationBarHidden:YES];
I hope this helps.
Upon completion of this question, I tried one final test.
[mainView.navigationController setNavigationBarHidden:YES];
This worked. It would appear that something in the process of embedding the mainView in the SWRevealViewController caused the navigation bar in the mainView itself to become visible, even though by default it was not.

How to change the modalPresentationStyle when the modal view controller is already shown?

I want to set my UIModalPresentationFormSheet style modal view to become UIModalPresentationFullScreen style sometime,but when it's already shown with UIModalPresentationFormSheet style,it can't goto fullscreen using code"[xx setModalPresentationStyle:UIModalPresentationFullScreen];"
Is there a way to change the present style after a modal view shown? My code like this:
UITableDownload* vc = [[UITableDownload alloc] initWithStyle:UITableViewStylePlain];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
[nav setModalPresentationStyle:UIModalPresentationFormSheet];
[MainAppDelegate mainBrowserViewController] presentModalViewController:nav animated:YES];
...//after shown,sometime I implement following code:
[nav setModalPresentationStyle:UIModalPresentationFullScreen];//(The "nav" object is the same as above code)
//But the change style code takes no effect.
This is still a question for me in an iOS 7 app and at this point I'm left to conclude that changing the modalPresentationStyle after the transition has occurred just has no effect.
Not sure if this is the answer or not, but have you tried accessing the controller via the modalViewController?
Something like:
[self.modalViewController setModalPresentationStyle:UIModalPresentationFullScreen];
rather than the:
[nav setModalPresentationStyle:UIModalPresentationFullScreen];
I think, you can try to change modalpresentationStyle as UIModalPresentationPageSheet
[nav setModalPresentationStyle:UIModalPresentationPageSheet];
This type should autorotate your modal view

presentModalViewController not displaying toolbar?

I have a viewcontroller I am trying to display as a UIModalPresentationFormSheet, however it does not show its UIToolbar. How can I make a toolbar show up on it?
ConnectionEditViewController * connectionEditViewController = [[ConnectionEditViewController alloc] initWithNibName:#"ConnectionEditViewController" bundle: nil];
connectionEditViewController.modalInPopover = YES;
connectionEditViewController.modalPresentationStyle = UIModalPresentationFormSheet;
connectionEditViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController: connectionEditViewController animated: YES];
Create a UINavigationController instance, set the rootViewController to be your connectionEditViewController, then configure the modal properties for the UINavigationController and present that.
If this is on iPad, it should pop up the view with the Navigation Bar as a grey toolbar at the top.
Configure the navigationItem of the connectionEditViewController to configure the nav bar.

Resources