How to create a fluid UI with interface builder? - iphone

Is it possible to create a fluid UI with interface builder?
For example, say I have a page that has a few fields at the top, some of which are optional. Can I make some of them invisible and have the fields below move up to fill the gap?
Similarly, if I have a tableview in a page followed by a text field, can I have the tableview grow and shrink and still have the text field immediately after it?

The best you can do with interface builder is setting autoresizing masks. So if your view container changes dimensions the iPhone can adjust sizes accordingly.
To answer your questions:
1: You can't accomplish the functionality directly with interface builder, You can setup your interface but then you'll have to write the logic in the controller to achieve that functionality.
2: This you can accomplish in interface builder. You add the textField to the footerView of the tableview, and then the text field will always remain at the bottom of the tableView no matter what is displayed in your table.

Related

Auto resizable collection view cells in Swift

I want to create collection view cells the width of which changes according to the label in them. The labels of the cells get their text value from an array declared by me. Is there a way to create auto resizable collection view cells which change their length accordingly without using custom classes or pod files?
Try experimenting with UIStackView. I'm pretty sure the elements can be auto justified. You'll likely be able create the layout you want with vertical and horizontal stack views.
If you select multiple views in the interface builder that are arranged horizontally or vertically you can embed them in a stack view.
if you multi select the views you want and press that button in the lower right corner of interface builder you should have an option to embed the views in a UIStack View

Nested UIStackViews in UITableViewCell not working with constraints

I have a simple table view controller. Section 0 will be a single cell with a couple of labels, textfields, and a few buttons. I wanted to use stack views to layout the fields neatly. The moment I add any constraints I get the whole thing off the cell and not visible. The one button that is alway visible isn't even the correct width. The cell height is plenty large enough to hold it. It looks perfect in the interface builder, and has no errors or conflicting constraints. What am I missing?
Then image with the fields all there is without any constraints.
In the Interface builder
ScreenShot

make view controller scrollable with collection view

I need to create a view controller like this or like user instagram's profile
not exactly same, I just want to add label and buttons and collection view,
but I want all of this in scroll viewController
I think I can't do that from storyboard, so how I can make a view controller scrollable programmatically?
and then I want to add the label and buttons inside the scroll , I can do that programmatically , but how I can add collection programmatically inside it?
One of the possible solutions is to make the whole container a "UICollectionView" -or "UITableView", depends on what exactly you want to build-, and then, create a custom cell for each area depending on what do you want to display in it.
It might sounds a little bit strange in the beginning, but you will notice that it is a great technique to handle scrolling in your scene, including some of extra nice features, such as:
auto scroll content resizing for "UIKeyboardWillShowNotification" and "UIKeyboardWillHideNotification" events.
the ease of showing and hiding sections from the UI (actually they are cells!).
UPDATED: For example:
You can make the first part (red rectangle) as a UICollectionReusableView and customize it by adding your images and button in it, second part (blue square) as a UICollectionViewCell and so on...
This is the general idea of what how you can do it.

iPhone UI controls

Which class is used to create the clickable sections(with > arrow) and the checkbox list on last shot?
alt text http://developer.apple.com/iphone/library/documentation/uikit/reference/UINavigationController_Class/Art/navigation_interface.jpg
Have a look at the UINavigationController.
To create the list with arrows, use the UITableView and set the Accessory "Disclosure indicator" on the cell (in the Interface builder).
The screenshot is from the Settings application though. If you want to create subpanels for settings, you need to use a different approach (Here is one example)
UITableView (UITableViewController).
The checkmarks and arrows are added by changing the .accessoryType property of the cell. To make the table views clickable, implement the -tableView:didSelectRowAtIndexPath: method in the delegate.

iPhone -- customizing a grouped table view in Interface Builder

I am writing an iPhone app. According to the design, it is supposed to contain a lot of grouped table views. In these views, the rows are frequently not similar to each other. For example, on one screen, one row is the name of a task, another is its owner, another is its description, yet another is its history (which is supposed to be an expanding box), and so on. These rows are edited in different ways. For example, the name can be entered free-form, but the owner has to be chosen from a list, which would be brought up in a further table view.
I think doing all of this programatically would drive me batty. What I want is a way to design these screens in IB. But I can't figure out how to get IB to do treat the cells individually. Is that possible?
Thanks.
In Interface Builder you create custom UITableViewCells for each row and then return the appropriate custom cell in – tableView:willDisplayCell:forRowAtIndexPath:. You also need to return the height of each custom cell in – tableView:heightForRowAtIndexPath:.
Within Interface Builder, you create a custom cell just like you would any view. You size the cell and then fill it with subviews. It's best if you create a UITableViewCells subclass for each custom cell that has IBOutlets that connect to each subview. That way you can easily access labels, imageviews, controls etc.