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?
Related
I had used the UIPageViewController. This type of Controller will take up the entire Page Of VC to display with the 3 dots at the bottom.
I have been searching on internet for customize UIPageViewController with no success.
This is my problem:
in a VC:
1) Display UIPageViewController at the Top so there is space to display other UI in the middle and bottom of VC.
How to display UIPageViewController in a fixed size,say, 320 x 240 with 3 dots (indicators) immediately below the display image in a VC?
Thanks
To put a UIPageViewController's view anywhere you like in the interface, make it an embedded view controller. In other words, you have a parent view controller and a child view controller, where the page view controller is the child. There are strict rules about how to implement a custom parent-child relationship, but if you do it according to the rules, the frame of the page view controller's view is then completely up to you.
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.
My app is using a navigation controller and it has a navigation bar, a table view and an image on each view. Those elements layout from top to bottom with no overlapping.
Now because I have the exactly same image for every view (a logo), is it possible to animate only the navigation bar and the table view while the views push and pop? I want the logo always stays on the screen.
Thanks in advance.
Interesting idea. You might try adding the view directly as a subview of the navigation controller's view, rather than making it part of any of the controllers it manages—in that case, you probably also want to give the view a particular tag, then retrieve a reference to it in your individual controllers' -viewWillAppear:animated: and call -bringSubviewToFront: with it on the navigation controller.
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.
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.