I have an app which uses a large custom header (see pic). There are two ways I can think of structuring this:
Subclass UINavigationController and add the header there. Unfortunately, I can't edit topLayoutGuide or layOutSubviews, so child layout is a problem.
Just hide the navigationBar and put the custom header view in each child.
Is there any way to manage child layout in the case of #1? I also use UIViewControllerAnimatedTransitioning to animate the views. Would that make one solution preferable?
Related
I want multiple UIViewControllers holding a UICollectionView to look the same in constraints, size and cells, including textFields and UIImageView inside the cells.
This is how I want my views to look (roughly):
How can I decide of a uniform layout for all Collections ? (If one is changed - all others should be changed too)
Two options depending on what you need:
You need one base UIViewContoller class that holds a collection view and search bar - let's call it CollectionViewController - and make other view controllers inherit from it. Then a change in the CollectionViewContoller will apply to the other controllers. Unfortunately this cannot be done in storyboards. You can look here: How to use single storyboard uiviewcontroller for multiple subclass - suggestions are to use either a xib file to make a view with the needed subviews or make the whole view controller in code.
Use only one view controller and change the data you load into it depending on what you need.
I want to launch a XLForms view controller as a Form Sheet. I want the controller to have a toolbar at the top and then the XLForm tableview underneath it. How?
The view controller isn't a navigation controller and so I need to add a toolbar at the top (or bottom) where I can add buttons. So how do I do this?
It turns out that this is not too difficult. I just wish that it was documented somewhere.
All the sample code I could find showed the top view controller inheriting from XLFormViewController. In this case, the IB controller only requires a topline view.
I wanted to expand the view controller to have other components in it other than just a "View" object. I wanted a toolbar across the top and a couple of other things.
So, here's how I did it. I'm not sure that this is the best approach but it did work.
Create the View Controller in IB and add all the components you want.
Include a TableView object someone in your design
Go into the "Assistant Editor" and hook the TableView object to the "tableView" object defined in XLFormViewController.h by ctrl-dragging and dropping on the IBOutlet tableView object.
All other controls work as usual.
Important:
Do not treat the tableView object like a regular object. In other words, do not implement UITableViewDataSource and UITableViewDelegate methods.
Hope this helps.
Basically until now I create a ViewController in the Storyboard, set its class in the identity inspector and implement the connections and behaviour in the class.
Now I have two ViewControllers (ViewControllerFoo and ViewControllerBar), both are visually the same, but the information and the implementations of the actions of the buttons are different. So I want to create a BaseViewController, with the view creation and common implementation and override some methods in the ViewControllerFoo and ViewControllerBar
If possible I'd like to keep both ViewControllers in the StoryBoard in order to create the segues that launches each one of them visually
How can I do this?
Note: I'm starting with iOS development.
View layout is something that works with view not with view controller.
You can create a simple .xib (or view) file and draw your layout here.
After that add this view to controller or specify that view as main view of this controller.
Or you can create a view class and place all elements programmatically.
Just think about storyboard as 'navigation' utility not 'view layout' utility.
Note: too many views on storyboard speed down your computer and look too ugly.
Draw view in xib to reuse it or create custom views classes/clusters to implement interesting UX/UI effects
Is it possible to change the way UITabBarController's look?
For example to arrange the tabBarItems vertically (instead of horizontally) and in the center of the view (instead of locked to the bottom)
For the changes you want, no.
What you are describing is an entirely custom interface that you will need to design from scratch.
It's impossible using the UITabBarController component. But you can use a UIView with lot of buttons that perform the same function of the UITabBarController buttons and place them as you want.
No as the other say, you can't. You can customize visually only the UITabBar using appearance API, but you can't change its layout.
What you want to do can be easily achieved by using the UIViewController container API (Read Managing Child View Controllers in a Custom Container) and simple view. Or using storyboards with custom segue.
I'm using XCode 4 and storyboarding an application I'm creating, however I cannot visually modify the UIToolbar.
I'm attempting to modify a UIToolbar that is inside of a UITableViewController - however I have to place the UIToolbar out of the correct hierarchy in order to be able to modify it visually. I've tried placing it onto the view controller area but that does not make it show up.
At one point I was able to make it appear below, as it's own object however I was not able to recreate that.
Once I was able to get it to look like this
Your UITableViewController is inside a UINavigationController, which already has its own UIToolbar—you don't need to drag a new one into your view hierarchy. Interface Builder can simulate the toolbar for you under "Simulated Metrics" in the inspector panel.
Once the simulated toolbar is visible, simply drag UIBarButtonItems into it. Use a custom item with a custom view if you need anything more complicated than a button or spacer.
If you need your toolbar items need to be dynamic, you can maintain a reference via IBOutlets without necessarily having them in your view. Then set your UITableViewController's toolbarItems property or call -setToolbarItems:animated: at runtime to display the appropriate items.
See Apple's UINavigationController Class Reference: Displaying a Toolbar.
To answer your question, the visual editor simplifies the setup of most controls, view hierarchies, and delegation patterns, but it's still up to the developer to make sure they check out. The implementation of UITableViewController makes certain assumptions and assertions about its view hierarchy that Xcode does not enforce through the visual editor. Given that your desired view hierarchy is unsupported, I have to assume that the editor's behavior is either undefined or irrelevant. For a workaround, see Maxner's suggestion.
UITableViewControllers only allow one view object, which of course is UITableView. UITableViews are not cooperative for subviewing and they usually push everything into footers or headers. Something like this isn't possible:
-TableController
-Table
-Subview
-Another subview
UITableViewControllers are reduced to this:
-TableViewController
-Table
So you will need to use a UIViewController and declare a UITableView in there. Heres the Hierarchy you should use then:
- ViewController <Table's Delegate & Data Source>
- View
-Table
- Your UIToolbar
In your ViewController.h declare IBOutlet UITableView and connect Data Source and Delegate to the ViewController. Then simply add the UITableView implementations to your .m file and you're good to go.