I have a Tabbar application with a navigation controller (classic).
At some point when a url is selected a WebView controller is displayed with the appropriate url address.
I want to be able to use the tabbar area placing the webview over it. I tried
[self.tabBarController.tabBar setHidden:TRUE];
but this just makes the tabbar white.
How can i do this?
Teo
You can use theView.hidesBottomBarWhenPushed. Then when you push the view onto the navigation stack, the bottom bar (tab bar) will be hidden.
If you want to hide the tab bar from within the view itself, afaik the only way is to hide it by either using .hidden = YES or changing the frame. Then you need to change the frame (more specifically the height) of the view to fill the empty space.
Changing the height will not do anything because the tab bar is still sitting on top of the UIView which is holding the UIWebView. You need to do something to this extent:
[[[[UIApplication sharedApplication] delegate] window] addSubview:webView];
The only issue I am having now is that the webView is being pulled behind the UIView that is holding it. : (
I guess you can put an IBOutlet hook in there and perform a sendToBack on the UIView but I am going to keep searching for a better solution.
Related
I've been trying to add a UIView (with a UIImageView) as an initial screen when the user launches my application for the first time. However, even after I hide the tab bar, or move its frame out of the screen, the UIView still crops itself as if the tab bar was still there.
Both of these code blocks produced the same result:
[appDelegate.tabBarController.tabBar setFrame:CGRectMake(0,1000,0,0)];
[self setView:InitialView];
and
[appDelegate.tabBarController.tabBar setHidden:YES];
[self setView:InitialView];
Here's a screenshot of the incident in action:
Does anyone know how to fix this problem? I've been puzzling away at this for the past few hours, and I can't seem to do anything about it.
Presumably you have your view's view controller inside this tab bar controller. As a result, the view controller's view is getting sized appropriately to fit inside the tab bar controller's view. Why don't you just get the frame of the tab bar and adjust the height of your view by the view's current height + the tab bar's height?
As a side note, I am assuming InitialView is a UIView (or subclass) instance. It is standard Object-Oriented Programming convention to name instances of classes with a lower case letter, and then to proceed in camel case, as in initialView. Just an FYI.
Try this reference your App Delegate which should take in account the UITabBarController. Just the UIImageView as a subview, and when you are done just remove it. You'll obviously have to import your AppDelegate.
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication]delegate];
[imageView addSubview:appDelegate.window];
I am developing one application.In that I need to decrease the UINavigationBar size, For that I use the below code.
CGFloat navBarHeight = 10.0f;
CGRect frame = CGRectMake(50.0f, 0.0f, 320.0f, navBarHeight);
[self.navigationController.navigationBar setFrame:frame];
But when I go to next page, that page Navigationbar also changed.But I need to change only one page. And I want to separate the back button and place before navigation bar.So for that i place one button before UINavigationBar.But I don't perform it action.
So please tell me how to do this one.
Thanks in advance...
What you need to be aware of is that the Navigation Controller manages an entire view hierarchy. When you have ViewControllerA, in which you alter the navigation bar of the navigation controller's height, and then push ViewControllerB onto that navigation controller's stack, you are effectively looking at the same navigation bar. You will need to change the height back to it's original in ViewControllerB.
I'm not sure what you mean by "Separate the back button and place before navigation bar". Do you have a picture or could you clarify the question?
UPDATE: Based on your comment, what you are trying to achieve is possible, but a bad idea. A UINavigationController's navigationBar spans the entire width of the screen. Regardless of the technical feasibility of shortening the width of this bar to show your button to the left of it, this arguably infringes on the HIG's, which require standard use of standard iOS features; i.e. the navigation bar should always span the width of the device in either orientation. If you are looking to replace the standard back button with a different button, that is possible by simply replacing the leftNavigationItem, i.e.
self.navigationItem.leftNavigationItem = <SomeUIBarButtonItem>;
You probably want to set hidesBackButton = YES, as well.
UPDATE 2: I tested this in a small Xcode project, and you can change the width of the navigation bar. It looks silly, but it's possible. However, if you use a nib and set the NavigationBar property on that nib, when you add your button to the view controller's view, you have to set the y value of the frame to a negative number to get it in line with the nav bar. Even still, setting text or target/actions on this button don't seem to work. The navigation bar might reserve that width for itself. Removing the nav bar setting from the nib and trying again still doesn't do it. The presence of the navigation bar (or, really, the navigation controller, most likely), seems to prevent anything else from receiving touch events in that area.
You need to change size of UINavigation bar in every page.
Regarding return button I used this solution:
-(void)returnButton:(id)sender
{
[self.navigationController popToRootViewControllerAnimated: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 have an application with a tab bar and a navigation bar. I push a view controller that is used to show photos, one at a time. It initially shows the bars and forward/back controls; after a delay, these hide, using setNavigationBarHidden:animated: and a custom transform (CGAffineTransformMakeTranslation) on the tab bar. This works, but the view controllers view , which shows the photo, leaps up and down. The same is true if I leave the tab bar out of the equation.
How can I prevent the UINavigationBar from moving my view around? I would like the photo to stay fixed in the screen, with the nav bar dropping down over the top segment of it.
Had this issue and fixed it with a class that inherited from UINavigationController
-(void)viewWillAppear:(BOOL)animated
{
self.navigationBar.translucent = YES;
}
Worked great for me, didn't had to set style to UIBarStyleBlackTranslucent. So it did kept my colors.
[[navigationController navigationBar] setBarStyle:UIBarStyleBlackTranslucent];
[[navigationController navigationBar] setAutoresizesSubviews:NO];
this seemed to do the trick for me!
I know this is an old question, but I accomplished that by disabling 'Autoresize Subviews' in Interface Builder
I haven't been able to find a proper way to handle this except to set the navigationBar style to translucent as in:
theNavigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
Other than creating another navigation bar and adding buttons to them, that's the best (and it seems to be what Apple does as well in it's Photo app)
I have a small multiview app. It consists of a UITabBarController with a nav controller in each tab. What I want is to show a UIImageView when a user shakes the device. After I've implemented the loading of the UIImageView, I faced a problem-the image was only 2/3 of the screen because of the tab and nav bars. I managed to hide the nav bar but I'm still stuck with the tab bar. I tried many solutions such as [tabBar setHidden: YES]; but I get errors "tabBar undeclared", although I've imported the AppDelegate, where the tabBar was defined.
Thanks in advance!
Try setting
myViewController.hidesBottomBarWhenPushed = YES;
when you create your UIImageView. When you push it on to the view stack the UITabBar will hide automatically, and it will be restored automatically when you pop or dismiss the controller. No need for the application delegate.
If you want to show a full screen view, it is best to use a modal view controller. This way you do have to worry about hiding/showing navigation items. Take a look at:
http://developer.apple.com/iphone/library/featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html
to get started.