I have this UINavigationControl that has its toolbar visible and is showing the RootViewController. Then I push a new viewController into the screen but I like the toolbar to be invisible, while this other viewController is being shown.
Then, to show the viewController and hide the toolbar of the UINavigationControl I do this:
self.navigationController.toolbar.hidden = YES;
UIViewController *newVC = [[UIViewController alloc] init];
[self.navigationController pushViewController:newVC animated:YES];
The problem is that any touch on this new view controller in the are correspondent where the toolbar was visible on the last view controller is not detected.
As you know, the toolbar sits on a rectangle at the bottom of the screen, has the screen width and 44 pixels high (if I am not wrong). So, the new pushed view controller responds to touch on its full view are except those on this rectangle.
See the following picture. I have 3 buttons. Buttons 1 and 2 will respond to touches, but not button 3, because it is inside the area where the toolbar of the other view was...
And more than that, if I paint the background color of the new view with red, for example, the whole screen will be red, except for that bottom rectangle that will be white (and white is not the color of the previous view). I have checked and the view has 320 x 480...
any clues? thanks.
I think you are looking for hidesBottomBarWhenPushed property of a UIViewController.
See this related question here.
Related
I've been requested to mock up an app with the following design.
The large gray box is the main view area. (UIView)
The 2 pink squares are buttons. They are almost like tabs of a tabbar in how they should function.
What I am struggling to achieve is to get 2 UINavigationbars/Controllers to appear in the UIView(large gray box) when a button is pressed. Not at the same time of course, but which ever Navbar/Controller/View that is shown is dependent on what button was selected.
I can make a UIViewControllers view appear there ok by doing the following
TabViewOne * vcTab = [[TabViewOne alloc] initWithNibName:#"TabViewOne" bundle:[NSBundle mainBundle]];
[self.mainView addSubview:vcTab.view];
That makes the view of TabViewOne appear in my mainView area (gray box).
What I would actually like to happen is that I can get my view to appear here but with a navbar and all the functionality that it brings. I will eventually just hide the nav bar but use its functionality to move up and down the view stack.
This is what I tried to get it working but the view stays blank when I try this :
TabViewOne * vcTab = [[TabViewOne alloc] initWithNibName:#"TabViewOne" bundle:[NSBundle mainBundle]];
UINavigationController * navVC = [[UINavigationController alloc] initWithRootViewController:vcTab];
[[navVC navigationBar] setHidden:YES];
[self.mainView addSubview:navVC.view];
Could somebody please advise me how to do this properly?
Many Thanks,
-Code
You can achieve your requirement from a small trick. You can implement a tab bar controller there. In tab bar controllers each tab can be run inside a separate navigation controller. In the root view controller of both the tab items you have to have that 2 button design. If you use a generic view and add it as a subview you can easily reuse it. Next thing is it will appear the tab bar at the bottom of the view as you have a tab bar controller there. You can hide it simply by making its frame rectangle to a non visible position. After that your tab selection should be done manually based on the users button click.
In my application in RootViewController i have added a top custom view with titleview & a button similar to UINavigationController and bottom Custom View similar to UITabBar in between i'm having a view(say, contentView) with 320 x 280 dimension view in which i'm adding different different subview as per the user selection of tabs.
In one tab inside my contentView i have a button to open camera, there i'm presenting Camera or PhotoLibrary like
[self presentModalViewController:imagePicker animated:YES];
but is presenting inside my contentView, so that capture button & camera controls are going behind my navigation bar,below is the snap. Img 1. is normal scenario, but for me its like img.2
How to overcome this,Any help is thanks in advance.
I have a TabBar on the screen and a View with some buttons on it. When a button is clicked, I create a ViewController (with a view from a nib) and add it to the keywindow of the application. I put this view offscreen and start an animation to make this new view slides from the bottom of the screen, and cover the tabBar. On this new view there is a UIPicker and 2 buttons (select / cancel). When one of this buttons is clicked, the PickerView slide off the screen and his controller is dealloc.
This works fine except for one thing : if I click on the zone where the tabBar is located and hidden by my new view, the tabBar get the click event !
How can I make the tabBar non responsive ? (Remember that I don't push the new view) Or maybe it isn't the right way to do this ?
EDIT & ANSWER : The problem came from the fact that I did a mistake in the height setting. I typed 160 instead of 260.
[myPickerController.view setFrame:CGRectMake(0, 480, 320, 260)];
The last 100 px, even if displayed, where "transparent" to event and get transfered to the TabBar who stands in that zone (even if it was hidden).
I am not sure but why don't you try
yourTabbar.userInteractionEnabled = NO;
when the view is visible. Make sure you set
yourTabbar.userInteractionEnabled = YES;
when view is dismissed.
You should use method named in your application:
tabbar1.hidesBottomBarWhenPushed = YES;
I have an application with a navigation bar and a tab bar. A user can navigate to a view which displays images in a scroll view. I'd like to have the same behavior as the iPhone photo app: Nav bar at the top, tool bar at the bottom, which will hide or show based upon a tap.
I'm moving my view to the window object in order to achieve full screen mode. This works fine:
myView = [self.view retain];
self.view = nil;
[window addSubview:myView];
But when I want to redisplay the Nav & tool bar, I run into a problem. The bars show fine, but the view is empty, and I can't seem to add any content to the view:
[myView removeFromSuperview];
self.view = myView;
I got a lot of good info from this post
but can't quite get the right combination.
By simply setting the controller's view, you aren't adding it as a subview to anything else, so it will never appear.
Moving views around like this can get a little tricky. I recommend that you not move the view from one to the other, but instead have two UIViews. Add second UIView to the window's subview and set it to hidden=YES initially. When you want to show it, set the image for the UIImageView, and then set the hidden property to NO.
what's wrong with just using setNavigationBarHidden: animated: and setToolbarHidden:animated:?
I've checked the other answers but have not found anything that really describes my situation. So here goes.
I have a window-based app that creates and loads a UIViewController from xib. It has status bar disabled, height of 480 and a UISegmentedControl with y origin of 451. It displays nicely at the bottom of the screen.*
In viewDidLoad of the UIViewController I create a UIView initWithFrame:CGRectMake(0.0, 0.0, 320.0, 431.0)]; (that's 480 - 29 pixels for the UISegmentedControl and 20 for the status bar.) I add it to the UIViewController with [self.view addSubview:gameBoard];. Then some UIView game pieces are added as subviews of the gameboard UIView and everything is displayed as I think it should be.
When some of those UIView subviews are tapped, a menu should appear. I have created a UIViewController with the required controls on it. I use a delegate method to call from the subviews, who pick up the triggering events, to the root UIViewController - which does
self.squadOrders = [[SquadOrders alloc] initWithNibName:#"SquadOrders" bundle:nil];
squadOrders.viewControllerDelegate = self;
[self presentModalViewController:squadOrders animated:YES];
And the modal dialog displays as I think it should, sliding up from the lower edge of the screen, not covering the status bar but covering the UISegmentedControl mentioned at the bottom of the root UIViewController. It gets dismissed by
[self dismissModalViewControllerAnimated:YES];
and that's where the trouble begins. The UISegmented control is moved down by 20 pixels so that only 9 pixels of it is visible at the bottom of the screen. There is a 20 pixel white gap at the top where the view has been moved down.
*enabling the status bar on this or any other xib does not change the described behavior at all.
Other stackoverflow questions related are:
IPhone - After dismissing Modal View Controller - gap is left at top of page - but the given solution was don't have another view controller loaded as a subview of the view controller that displays the modal - but I don't, only UIViews. There's also the suggestion of just resetting the appropriate frame after the modal goes away but it feels like cheating.
Contents of UIScrollView shifted after dismissing ModalViewController - I've played with the heights of all the views and controllers - am sure they match, hasn't helped. Again, the frame can be reset but it only addresses the symptom.
There are others but nothing is solving this issue so far.
I've just solved this issue with view shifting down.
It was because of navigationBar.barStyle set to UIBarStyleBlackTranslucent.
This is a hack, but might help somebody. I was having plenty of these 20 pixel gap issues throughout my app and they all went away by using a navigation controller as my root view controller. I don't really use it as a nav controller at all (and I hide the nav bar), so this solution can work in most apps.
Basically, I have a BaseView (320 x 480, no status bar) whose controller sits in my nav controller, and then the rest of my app is added as subviews to the BaseView. It all works great now.