I have a UIImagePickerController that is shown
[self presentModalViewController:self.picker animated:NO];
Then later on the code, I allow the user to display a preference panel :
PreferencesController *nextWindow = [[[PreferencesController alloc] initWithNibName:#"Preferences" bundle:nil] autorelease];
UINavigationController* navController = [[[UINavigationController alloc] initWithRootViewController:nextWindow] autorelease];
[self presentModalViewController:navController animated:YES];
At this point, the new controller raises on the screen, but don't go to the top.
Some space is left "transparent" at the top (I can see the camera view behind), and the bottom of the view is hidden out of the screen. The space I am talking about is about a status bar height. The status bar is not present on the screen.
The navigation controller is hidden :
self.navigationController.navigationBarHidden = YES;
There is a toolbar at the top of the view. Nothing special into the view.
The height of the view is defined at 480. All simulated element are set off in IB.
The autoresize properties are all set on.
I had a previous xib (I rebuilt it from scratch) that worked very well. I don't see what I missed on this one (I have only changed the xib, that replaces the previous one).
I've cleaned the cache to be sure there was nothing left. No change...
I've deleted everything in the new view to prevent some conflicts. No change...
What did I miss ? How could I remove this empty space ?
Try presenting the second modal view controller (the preferences one) from self instead of self.picker
ModalViewController loading on top of another Modal
Edit:
Try setting wantsFullScreenLayout = YES
After some searches and some other problems, I've found a final solution to the problem through this question
I had to call :
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
at the application start.
Related
I'm looking for a way to have a navigation bar not show up on a screen at all.
I know there is a setNavigationBarHidden:animated: to use on the navigationbar, but this still shows the bar on the screen for a split second before removing and readjusting the screen dimensions.
I've tried moving the setNavigationBarHidden:animated: to the viewDidLoad:, viewWillAppear: etc. and set it hidden on the previous activities viewWillDisappear: but it will shows up on the next screen.
How do I make it such that the view loads with out a navigationbar on it before it is shown?
Thanks,
Dman
I'm hiding the navigation bar for the UINavigationController in the AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method and works fine for me. At some point, while navigating through the screens, I'm showing it then hide it again. Works like a charm.
UIViewController *controller = [[UIViewController alloc] init];
UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController: controller];
navCtrl.navigationBarHidden = YES;
self.window.rootViewController = navCtrl;
[controller release];
[navCtrl release];
Hope this helps.
P.S. Actually I never show the navigationBar of the navigation controller again. On the controllers that need the bar I'm adding a new one.
You could try and do
setNavigationBarHidden:animated:
in your view which is calling the view where you don't want it to be displayed just before you call your new view. If they have the same navigationcontroller, it should already be hidden if it appears
if not, you try to set it on the navigation oder viewcontroller before your present it...
I have put one global tabBarController in iphone app that I have been working on.
But in one of my screen I needed to put the local tabBar which is different from the global tabBarController.
I have done it in two ways:
1) Hiding the global tabBar by self.tabBarController.tabBar.hidden = yes; and putting local tabBar in place of it in the view. But the frame of tabBar is showing blank white.
2) Tried by adding the local tabBar as subview of global tabBar which worked but after screen is unloaded its not removing the local tabBar though applying [localTabBar removeFromSuperView];
Thanks in advance..
Global tabBarController:
tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = [NSArray arrayWithObjects:ActivityTabnav,nav2,privateChatnav,ExploreTabnav,nav3,tempTabnav, nil];
localtabBar is a tabBar on view xib of viewController.
in vIewDidLoad >
UIWindow* window = [[UIApplication sharedApplication] keyWindow];
[window addSubview:self.tabBar];
in vIewDidUnLoad >
[self.tabBar removeFromSuperview];
Previously I tried to add self.tabBar to self.tabBarController.tabBar as a subView which persisted the local self.tabBar in other screens.
Thank you...
The cleanest way I've found to do this is to set the hidesBottomBarWhenPushed property of your view controller, then place it inside a UINavigationController (hiding the navigiationBar if you don't need it). This will hide the UITabBarController's UITabBar without leaving a white space.
You'd then put the local UITabBar directly into the UIViewController's view;
Another possibility would be to hide the UITabBarController's UITabBar, then add the local UITabBar to as a subview of UITabBarController's view. Of course you'd have to remove from superview when needed.
One way is to add TabBar on Window. But be sure that you handle is correctly. You can add it on window by taking the Current Window object and then add TabBar onto it... as below...
UIWindow* window = [[UIApplication sharedApplication] keyWindow];
[window addSubview:tabbar];
this could be one option but handle it carefully...
Whe I create a new UIViewController and try to put inside a NavigationController in the usual way (drag-drop in the xib and create the outlet), I show the Navigationcontroller with:
[self.view addSubview:navigationController.view]
The result is a Navigation Bar with a little band in the upper part (seems displaced down), (i can't post the image now but is like 20px empty space)
I tried to put the navigation controller on the top window:
[[[UIApplication sharedApplication] keyWindow] addSubview:navigationController.view];
And it worked, but I'm unable to come back the initial screen whe I execute:
[navigationController.view removeFromSuperview]
or
[self dissmissModalViewControllerAnimated:YES];
It is possible to solve this?
UINavigationController* nav=[[UINavigationController alloc]init];
nav.navigationBar.frame=CGRectMake(0, 0, 320, 44);
NSLog(#"desc=%#",[nav.navigationBar description]);
[self.view addSubview:nav.navigationBar];
Try with above code. it will hide unnecessary space.
Thanks
20 pixels sounds like the status bar. Make sure in your nib that the status bar option for the view is set to None. Hope that Helps!
Everyone
I have a problem and I have been searching the solution but could not find any. I am working on a tab bar based app. Problem is that I want to hide tab bar at first screen and then show it on all other screens that are being displayed after first screen.
Can anyone please give me the best solution for this problem?
Actual scenario is that I have a screen that is login screen. Now i dont want to show tab bar here as tab bar will be displayed only if the user is signed in. When user logs in, I want the tab bar to be displayed showing its contents.
Best Regards
If you have your Tab Bar Controller as your rootController, you can use rootController.selectedIndex =0 for selecting 1st Tab bar Item, and rootController.selectedIndex =1; and so forth.
As soon as that particular view loads, you can load the other views in an array, and then add it to the rootController.selectedIndex and reloadInputViews with animation.
Edit: (as per the comments)
So you have a tab bar controller, and you want to show the introduction and the login screen while starting the App. If login is successful, you want to present the tab bar controller ! This can be done with ModalViewControllers
In the ViewDidLoad of the view that loads up first, (it's your first tab by default), add
//Declare Introduction Screen//
IntroductionController *introductionController = [[IntroductionController alloc] initWithNibName:#"IntroductionController" bundle:[NSBundle mainBundle]];
//Give a navigation screen for your introduction screen and set it to introduction screen
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:introductionController];
navController.title = #"Introduction";
navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:navController animated:NO];
Now your introduction screen would load as soon as your first tab bar loads. But the loading is instantaneous, so it's not visible to the user's eye. Now reference your Login View Controller like #class LoginController and create an object LoginViewController *lvc;, and synthesize it. Now declare LoginButton and in the IBAction
-(IBAction) loginAction: (id) sender{
NSLog(#"I clicked Login");
if (self.lvc ==nil){
self.lvc = [[LoginController alloc] init ];
}
lvc.title = #"Login";
[self.navigationController pushViewController: self.lvc animated:YES];
}
And in the LoginViewController, if Login is successful, just do
[self dismissModalViewControllerAnimated:YES];
create an outlet for the uitabbar, then declare it hidden in the first screen, then create a new void, NOT SENT SO IT DOESNT WORK in the first screen, make it say, lets say, hide. And inside hide, put code saying your uitabbar.hidden = YES; then, to make it work in the other view, write this in the viewDidLoad:
[(//first view*)[UIApplication sharedApplication].delegate //the void, in this case, hide];
Ok I have a view that we will call homeView. When a certain button is pushed on homeView, a UIPopOverController is presented in the following way:
self.studyPicker = [[[StudyPickerController alloc] initWithStudyArray:self.studyArray ViewNum:butto.tag] autorelease];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.studyPicker];
_studyPicker.delegate = self;
self.studyPickerPopover = [[[UIPopoverController alloc] initWithContentViewController:navController] autorelease];
[self.studyPickerPopover presentPopoverFromRect:CGRectMake(955,60, 22,10) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
Which works great. I get a nice big popover controller that displays my tableView data just the way I need it. Just as an FYI, in my StudyPickerController viewDidLoad method, I am also setting this:
self.contentSizeForViewInPopover = CGSizeMake(1000.0, 610.0);
Which allows me to make the size of my tableView nice and big. The problem I am experiencing is after I select a row in this first tableView. The navigationController pushes the new view just fine, but then the width of my popover controller gets cut in half! It doesn't make any sense! I have tried everything and can't figure out what is going on. In the new view, called ScreenView, it also has the same code in viewDidLoad:
self.contentSizeForViewInPopover = CGSizeMake(1000.0, 610.0);
An interesting observation that I've made but don't know what to do with is that if I take out the contentForSize code from the Second view in the tableView, or the one that I am trying to push to within the controller, when it pushes, it gets cut in half again, to the width of a standard popover controller you see in like Safari. But adding that code in makes it 2 times as wide, like there are two glued together or something, but it is still more narrow than the original width.
I don't know what's going on here, hopefully someone can help me out!
Thanks
Here is an image of the width it should stay:
And then here it is after it pushes the new view:
For each view you are presenting in the UIPopoverController, set the property
contentSizeForViewInPopover
For example:
myViewController.contentSizeForViewInPopover = CGSize(120.0f, 320.0f);
You will need to account for the size of the UINavigationBar (that you get from the UINavigationBar) inside the UIPopoverController but overall that controls the stretching and contracting of the UIPopoverController.