How to remove status bar from Modal ViewController in iOS App - objective-c

I am working on a Children's book app for iPad and my app opens up an Modal Window to be able to select Male or Female Narrator. I am unable to remove the status bar from the Modal Window. Pls. see attached screenshot (highlighted in yellow color). Also, how do I make the window look pretty or make is transparent as it doesn't look too appealing at the moment?
Here is the code logic to open the ModalViewController inside my Main Controller:
-(IBAction)appLinkGet{
[self loadSetupModalView];
}
-(void)loadSetupModalView{
NSLog(#"ChildrenBookViewController ==> loadSetupModalView::");
// Create a Navigation controller
UINavigationController *navController = [[UINavigationController alloc]
initWithRootViewController:self.setupViewController];
//RESIZE THE MODAL VIEW
navController.modalPresentationStyle = UIModalPresentationFormSheet;
navController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:navController animated:YES];
navController.view.superview.autoresizingMask =
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleBottomMargin;
navController.view.superview.frame = CGRectMake(
navController.view.superview.frame.origin.x,
navController.view.superview.frame.origin.y,
540.0f,
400.0f
);
//navController.view.superview.center = self.view.center;
[navController release];
}

Try using this method:
[navController setNavigationBarHidden:YES animated:NO];

Related

Why does my Navigation Bar temporarily disappear when I dismiss a modal view in iOS 7?

When I'm going back from my Modal View Controller to my Main View Controller (I have a horizontal animation) my Main Controllers navbar places itself a bit too high for a quick second and then jumps back to its right position. Does somebody know why? Ive been googling it but with no success.
App Delegate:
[navigationController.navigationBar setBarTintColor: [UIColor whiteColor]];
[navigationController.navigationBar setTranslucent: NO];
When i push button to open my Info View:
UIViewController *infoViewController;
infoViewController = [[InfoViewController alloc] initWithNibName:#"InfoViewController" bundle: nil];
infoViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController: infoViewController animated: YES completion:nil];
I'm not using Auto Layout on any xib-files. My Main View Controller xib-file is empty with Status Bar: Default. My Info View Controller xib-file has some stuff in it.
Code for closing my Modal View Controller:
-(IBAction)onBackBtnClick:(id)sender
{
[self dismissModalViewControllerAnimated: YES];
}
All what you have to do is to add the following code in the ViewWillAppear of the "InfoViewController" viewController class
-(void) viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController.navigationBar setTranslucent:NO];
[self.navigationController.navigationBar.layer removeAllAnimations];
}
Hope it worked with you :)
The problem seems to be
infoViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
If you change this to
infoViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
then it will no longer jump. This worked for me. Good luck!

iOS - Show UIPopoverController with TableView from Navigation Toolbarbutton

I would like to display a UIPopoverController in my iPad app when the user taps a button which is at the lower toolbar provided by my NavigationController. Is there a tutorial on how I can do this? All I found was ancient tutorials from 2010.
Thank you in advance.
-(IBAction)ButtunClickMethod:(id)sender{
//create the table view controller from nib
self.tblLisView = [[[tableListVC alloc]
initWithNibName:#"tableListVC"
bundle:[NSBundle mainBundle]] autorelease];
//set popover content size
tblLisView.contentSizeForViewInPopover = CGSizeMake(170, 170);
//create a popover controller
self.popoverController = [[[UIPopoverController alloc]
initWithContentViewController:tblLisView] autorelease];
//present the popover view non-modal with a
//refrence to the button pressed within the current view
[self.popoverController presentPopoverFromRect:popoverButton.frame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionDown
animated:YES];
}

I have no Navigation Bar in a view called with an IBAction?

My main menu (a ViewController) is embedded in a NavigationController that I added in the storyboard in Xcode4.
I have a button in my menu, displaying a new view. To display it I use :
- (IBAction) display : (id) sender
{
if(!anotherView) anotherView = [[AnotherView alloc] initWithNibName:#"AnotherView" bundle:nil];
[self presentModalViewController:anotherView animated:NO];
}
My other view is correctly displayed with all its objects and elements. Excluding my NavigationController's bar, that doesn't appear. Why ?
Thanks for your advices
You are presenting the view modally what you probably meant was
[self.navigationController pushViewController:anotherView animated:YES]
of course what you really want to do is not mix and match storyboard and non storyboard flows unnecessarily like this and have the storyboard do this for you
you are presenting your viewController modally. If you want to use the navigation controller you have to push your view onto the navigation stack.
replace
[self presentModalViewController:anotherView animated:NO];
with
[self.navigationController pushViewController:anotherViewController animated:YES];
You can still present your view modally without losing the navigation bar. Try this code:
AnotherView *tempAnotherView = [[AnotherView alloc] initWithNibName:#"AnotherView" bundle:nil];
[self setAnotherView:tempAnotherView];
[tempAnotherView release];
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:self.anotherView] autorelease];
[self.navigationController presentModalViewController:navController animated:YES];
Hope it helps! :)

Seamlessly flip from one modal view to another, without showing a solid colour background

I have the following UI for an iPad app:
When I click on the Settings button, I want the dialog to horizontally flip to show the settings dialog.
I have this working fine. But, there is a background colour shown when the dailog flips over. As you can see:
Is there any way to not have this block of colour be visible as the dialogs flip? I'd like it to look more seamless -- as if it's a sheet of paper flipping over.
The views are essentially this:
Window
Main View. Set to the window's rootViewController
Login modal view
Thus the main window and root controller are setup as follows (in the app delegate class):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[MainViewController alloc] initWithNibName:#"MainView" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
The login window is setup and shown in the main view's viewDidAppear:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// Setup and show Login dialog
LoginViewController* controller = [[LoginViewController alloc] initWithNibName:#"LoginView" bundle:nil];
controller.delegate = self;
controller.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
controller.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:controller animated:YES];
}
And when the Settings button is pressed: showing the Settings modal view is done in pretty much the same way that the Login modal view was shown:
- (IBAction)settingsButtonPressed:(id)sender {
SettingsViewController *controller = [[SettingsViewController alloc] initWithNibName:#"SettingsView" bundle:nil];
controller.delegate = self;
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
controller.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentModalViewController:controller animated:YES];
}
I don't think there's any way to do what you want using the modalPresentationStyle. You'll need to implement the animation yourself using a transition animation using the following method:
+ (void)transitionFromView:(UIView *)fromView toView:(UIView *)toView duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion
With the UIViewAnimationOptionTransitionFlipFromLeft option.
In this case the new view you want to flip is not the content of the modal (the controller.view) but the modal frame itself, so experiment with just calling the method above from your settings button, and instead of passing controller.view, substitute controller.view.superview, and if that doesn't work, try controller.view.superview.superview until the animation looks right.
It will require some tweaking to work out exactly how to do it.

Presenting modal view controller from popover

I have a view controller that is inside a popover, and I want to present a modal view controller from it. Here's my code:
EditDateViewController *dateViewController = [[EditDateViewController alloc] initWithNibName:#"EditDateViewController" bundle:[NSBundle mainBundle]];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:dateViewController];
navController.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentModalViewController:navController animated:YES];
[dateViewController release];
[navController release];
The result is this:
alt text http://cl.ly/5300e4f8f5d440d3f850/content
For some reason, the navigation bar background is transparent (or black?) even though I did not configure it that way. I tried manually setting the tintColor property of the navigation bar in the viewDidLoad method of the modal view controller, but it had no effect.
Try this
dateViewController.modalInPopover=YES;
self.navigationController.modalInPopover=YES;