I've added a tab bar controller to my app delegate. In IB, I adjusted the alpha property and unchecked opaque, however in the simulator I get transparency over a white background, even though there should be content below it.
Perhaps, the containing View needs to be resized to the full dimensions of the screen? I'm using a nav controller with a tableview in this tab bar item.
What? You want your UITabBar to be translucent? A UITabBar is not a subclass of UINavigationBar, therefore the content from any view controllers the tab controller manages will not appear under the tab bar, if that's what you're trying to do.
Related
I have a view controller that's embedded in a navigation controller. Therefore this view controller has a navigation item at the top. One of the things you can do in ios6 storyboards is that you can set the title, prompt and back button for this view controller (because its embedded in a navigation controller).
That being said, when I specify a title and test the app, everything looks good. However, when I place a transparent UIView on top of the navigation item (such as where the title is), the title itself just vanishes. The text itself that I typed into interface builder is gone. I have proven this because if I delete the view I created, the text I initially had is gone.
I tried to mediate the problem by actually setting the title itself outside of the interface builder:
self.navigationItem.title=#"My Title";
But that doens't seem to work either. Does anyone have a clue as to how I can hide/show a transparent UIView on top of a navigationItem in a navigation controller?
EDIT
Any UI element I place in the navigation controller toolbar seems to prevent the underlying title text from showing up. This happens even if the element is marked as transparent AND its set to hidden.
My understanding is that Interface Builder is, more or less, mimicking what you would do if you did the same thing programmatically using the UIBarButtonItem class. The various items in a navigation bar are instances of the UIBarButtonItem class. This class has the following initializers:
– initWithBarButtonSystemItem:target:action:
– initWithCustomView:
– initWithImage:style:target:action:
– initWithTitle:style:target:action:
– initWithImage:landscapeImagePhone:style:target:action:
When you just have a title for the navigation controller, Interface Builder treats it similar to using the initWithTitle: initializer. Basically, this means that, under the hood, a UILabel class is created with the given title and that UILabel is used as the view for the UIBarButtonItem.
When you are dragging the transparent view over the title, however, Interface Builder is instead doing the equivalent of calling initWithCustomView:. This means that the view you are providing is being used as the UIBarButtonItem's view. In other words, when you drag the custom view over the title, you are not placing it on top of the title. You are replacing the title with the transparent view.
One option might be to create a view which has both a UILabel and the transparent view as subviews. Then place that view as the title for the navigation bar. If you give that UILabel the correct font size and shadow, it will look indistinguishable from the system's default title and you will also be able to have the transparent view on top of it.
In IB, you can drag a UIView to the center of the navigation bar, and this will replace the titleView that is there by default (you can do it in code with setTitleView:). If you make its background clear and add a label to it to hold the title, it will look like the default title. You can then add another UIView as the subview of this view, just like you would with any other UIView.
I have a UINavigationController that contains (from top to bottom) a UINavigationBar, a UIImageView and a UITableView. Every view I will push in the stack contains the same UIImageView at the same place (this is a logo).
I would like the logo to stay just below the UINavigationBar, with no animation when I push/pop views.
Is it possible ?
Thanks
The only way I can think to achieve this would be to add the logo image view directly to the main window in your app delegate. Position it so that it will appear directly below the navigation bar. Then you'll have to set the background color of your view controller's view to clear and ensure that the opaque property is set to NO. Size your view and set the autoresizing mask so that it will be anchored to the bottom of the screen (or to the top of a tab bar or bottom toolbar).
Basically, you need to set up your view controller's view in such a way that there is a portion of the top of the view that is completely transparent. If this is the case, then the logo image view you added directly to the main window will always be visible. When pushing or popping between view controllers using your navigation controller, just ensure that every view controller's view is similarly setup to be transparent at the top right where your logo image view appears. Even if the navigation controller animates the transition, the transparency at the top of your views should only show the opaque portions of your views being animated, along with the navigation bar and its subviews.
Hope that makes sense.
UPDATE: Per Noah Witherspoon's comment, a better approach would probably be just to add your image logo view as a subview of the navigation controller's view. You'll still have to size your view controllers' views so that their contents aren't obscured by your logo image view, but this approach overall is a lot cleaner.
I want a small UIWebView on a navigation bar. Is it possible since NavigationBar takes only UINavigationItem ?
If you want the UIWebView actually showing on the UINavigationBar, you can set the UINavigationItem.titleView property to point to it.
If you want to show the UIWebView on the screen when a new navigation item is pushed on the navigation bar, then you should be using the navigation bar with an UINavigationController.
In my application, I'm displaying a fullscreen image in a 320 x 480 frame. After I display the image, I fade the navigation bar out to allow the user to see the whole picture. When the user taps in the area where the navigation bar was, I would like to bring the navigation bar back.
This is very similar to what happens in the iPhone Photos app.
Unfortunately, after I've hidden the UINavigationBar, I can't process touches on the screen where the navigation bar once was. I believe this is because the origin of the parent view is right below the navigation bar:
Nav Bar http://shortybox.com/navbar.gif
How can I process touches in this area to bring the nav bar back?
You can override hitTest:withEvent: on UIWindow. See this answer.
Are you fading out, and then removing the bar from its superview? If you just set its alpha to zero, it will still trap your clicks. Try removing it, or hiding it.
It looks like there isn't currently an easy solution to this. The default UINavigationBar is gobbling up all of my events. I ended up hiding the default navigation bar throughout my entire application, and adding a dummy UINavigationBar in interface builder.
By doing so, I lost the default "Back" buttons that come with the NavigationController, but the app is now functional.
I have a view with tab bar at the bottom. This view is pushed on a navigation controller, so there is also a navigation bar at the top. Unto this view, I would like to show a table view, which I create from its own nib. When I add this view as a subview, it overlaps the tab bar.
Is there a way to make this subview automatically resize to the free space in between the top and bottom bar?
If not, what is the 'right' way of adjusting its size to fit?
-Vegar
In the interface builder make sure that you've set the navigation bar and tab bar spacers up. It should be the first list of options on the first tab in the Interface builder Properties view. This will make your view mimic the amount of space it has when loaded in the view.
From there you can also choose the option to clip the subview. The interface builder also allows you to set resize options for the view. If the subview your adding wasn't created in the interface builder you'll have to specify those options manually.
Lastly make sure that your appending the subview to the correct view, and not the tab bar controller or navigation controller.
Best bet is to make sure the subview your addings dimensions are appropriate for the amount of space you have by creating a frame using CGRect.