Not able to add footerView in UTableView through XIB - ios

I am trying to add FooterView(UIView) by dragging down on UITableview through XIB but can't.
Yes we can add it programetically (tableView.tableFooterView = myView) & also works with dragging view in Storyboard,
But I want right from XIB.

You cannot do this in a Xib. If you think about it, a storyboard is somewhat like a collection of Xib files. Thus, in a storyboard you can add a footer view as a kind of 'xib' embedded in that storyboard. A pure xib cannot contain multiple child xib's, so what you want is not possible unfortunately.

Related

UIStackView as a root view of a XIB

I'd like to create a small UIViewController that contains an UITextField and a UILabel going one after the other.
I've decided to use an instance of UIStackView to lay out the subviews.
However, I have to add a UIStackView as a subview of the parent UIView in XIB.
Is it possible to configure XIB the way that the root view of the controller would be of a certain class, eliminating the need for the extra view?
I've attached the current view hierarchy. I'd like to get rid completely off the topmost View.
Yes you can, you need just to set the stackview as the the root view of your view controller as following:
you can do the following:
1- create new file -> under the user interface choose "Empty"
2- then you will get an empty XIB
3- after that you can add your UIStackView from the UI Component picker
4- put your UITextField and UILabel
5- finally create your .swift file and wire it up with your XIB

Why there is no prototypeCell in View.xib?

When we add any UITableView to UIViewController through storyboard we will see screen like this
and there is an option for PrototypeCell top right side. But when we add the UITableView to View.xib we will see screen like this
and here there is no PrototypeCell. I am not understanding this why there is difference. Please explain.
It's different because when you drag and drop a UItbaleViewController in the UIStoryboard, it assume that you will use dynamic cells, and when you drag and dropped a simple UITableView it changed the property to static, which means that you will provide different UI and informations to each cells.
You can change the style to dynamic instead of plain if you want to have prototype cells.
PrototypeCell not available in xib file, storyboard only.
You can use separated xib for UITableViewCell in this case. (in storyboard case you also can use separated xib for cells)

Handling multiple Xib or fixing collapse and expand button on multiple Xib file

Now the situation is illustrated in this image:
I have an app having multiple Xib files calling in one main Xib and its class. I have added expand and collapse view which works on particular xib expand and collapse subviews as required and reduces/Expands Height too.
This works well for one xib section when all tabs of xib files are collapsed and the second xib won't change its y-coordinates, but I'm having a white space between. I want to fix it.
Note: Every xib contains a class referring to it. The whole app won't use auto-resize.
How can I solve this?

How do I add a footer to a UITableView using Storyboard?

Same as this question, only the proposed solution doesn't work for me. When I drag a view to the bottom area of a tableView, it tries to add it to the list of cells higher up:
I'm sure I'm missing something simple... I'm new to storyboards.
EDIT:
Maybe it is adding a "footer" (though, it doesn't label it as such), it's just not adding it low enough. I was ultimately hoping to add an item that would appear at the bottom of the screen (and stick to the bottom of the screen).
TIP: You can use the Tree view (outline view) on the left to arrange the Views (and sub views). I have done a lot of storyboard editing, and dropping things into table views rarely go to the correct hierarchy level in the tree view.
Create a New UIViewController
Insert a UITableView
Resize the tableview by dragging its dimensions
The attached picture has a UITableView on TOP of a UIViewController's UIView. Make sure that you set the delegates in the UIViewController's .m, assign the tableView as a property of the view controller, and then set the tableview's delegate property to the UIViewController object. i.e.: tableView.delegate = self or [tableView setDelegate:self]; also with datasource.
OR you can just click the tableView, on story board, and then drag its delegate and datasource property to THE UIVIEWCONTROLLER! not the view! You can do this by dragging it to the this highlighted part of the view controller's toolbar on the storyboard:
Either you can create a footer view programatically or you can load a view from UIView outlet
UIView *tempFooter=[[UIView alloc]initWithFrame:self.Footerview.frame];
[tempFooter addSubview:self.Footerview];
self.ItemDetailsTable.tableFooterView=tempFooter;
self.Footerview //View outlet
You need to set all the needed constraints of the self.Footerview to get the required layout of the footer view.But you don't need to set constraints for tableview footer itself.

How to edit cells on UITableView using XIB, just like Storyboard

I'm running on some glitch or may be functionality lack.
I cannot edit UITableView when using XIB, just like Storyboard does.
There is something i'm missing??
Apple does not allow being able to edit cells directly in an XIB. You have to create a separate XIB for the cell and in the table view data source return a cell with that cell subclass
Maximillian is right — so instead of designing your cells in a XIB, I would design it in a storyboard, which then you could link into a larger storyboard with RBStoryboard.

Resources