In my IB I have a navigation controller which has in it a view controller.
When I am trying to load this view controller from another navigation controller the scroll view is being displaced by the size of a navigation bar to the bottom. All other elements of my view are not moving except the scroll view.
Why does it happen and how can I fix this?
Thanks.
In the Size tab of the IB Inspector palette, ensure your scroll view has its autoresizing behaviour set to such:
Likewise, ensure the scroll view's super view is set with the same autoresizing behaviour.
Related
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.
Is it a Segmented Control?
About the featured view, is it purely a tableview? how could they make the Segmented Control to be permanent instead of scrolling with the table cells down below?
as Ertebolle says its a UISegmentedControl set as the titleView of the navigationItem.
You can also create elements within the view that don't scroll with the tableview by adding a UITableView as a subview of a UIViewController's view. Setting its frame property means that you can have a scrollable tableview in a fixed certain position in your view and other elements in the view that don't scroll with it.
Yes, I believe it is a UISegmentedControl. But it's set as the title view of the navigation bar - to reproduce the whole effect, you'd create a UINavigationController, push a UITableViewController as the top view in it, and set the titleView of the table view controller's navigationItem to that segmented control. This would automatically anchor the toolbar / segmented control on top.
I'm working on an iPhone app where I'm using a navigation controller (UINavigationController) to navigate through the various child views, and I would like to add a uiview to either the main window or the navigation controller, as a footer overlay that shows up on top of all the child views. I've tried this through interface builder, and programmatically, but nothing seems to work.
Working in interface builder, I've tried adding the footer to the bottom of the main window, and decreasing the height of the child views so the footer would show up, but the children seem to resize to fill the whole window. I've tried playing with some of the options, like 'wants full screen', 'resize view from NIB', tried to resize the navigation controller and couldn't. Same problem when I try to add it programmatically instead.
I can add a toolbar to the navigation controller in interface builder, is there a way to add a UIView instead? Or even attach a UIView to a toolbar? I'm sure there's a simple way to do what I'm trying, I'm hoping someone out there has had a similar experience.
Thanks!
If you want to have a toolbar sized custom view you can just position it where the toolbar would be and add it to the window as a subview above your navigation controller. Then you don't have to worry about autoresizing ruining your fun, you'll just always be drawing your view over the navController's toolbar.
[myWindow insertSubview:newView aboveSubview:myNavController.view]
Just make sure you adjust the size of your view if you want to respond to device rotations, as the toolbar size changes then.
You may also have success creating a view hierarchy that looks like this:
UIWindow
Subview 1: Custom view which holds app content
Subview 1a: UINavigationController with your main view as its root view
Subview 2: Custom view which holds your footer content
Subview 2a...2z: whatever views you need inside your footer
That way you can make your footer whatever height you want. Just set the appropriate autoresizingMask properties on your window's two subviews so that you can ensure proper positioning as well as respond to interface orientation changes automatically.
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.
I have a main view which has 3 labels positioned on the top. At the bottom there are about six buttons. On tapping each of the buttons, a different view is to displayed in the center area.
Each of those views have a view controller of its own. In the viewdidload method I set the view frame's y position and height so that it fits in the center area.
This all works if I add those views as subviews. But I want to maintain a view hierarchy. So I tried to use navigation controller. But the problem is the main view goes off screen and the child view is positioned from the top.
How do I solve this problem?
Do you mean the navigation controller supports adding of subviews without taking off the parent view from the screen?