How to attach Xib at the bottom of tableview - ios

I would like to attach a nib file with custom buttons and textfields at the bottom of a tableview. When i scroll the table and it reaches the last cell it must just continues to the attached nib without stopping scrolling. I want to achieve the same action as if its a footer on the tableview. How do i achieve such in objective c. An example or a pointer to a tutorial will be helpful.

This is a good article that I had used a while ago to be able to use Xib files in storyboards:
https://medium.com/zenchef-tech-and-product/how-to-visualize-reusable-xibs-in-storyboards-using-ibdesignable-c0488c7f525d

Related

How do I implement the below view in iOS (Objective-C or Swift)?

Basically I'm trying to implement the feature which is attached as an image. I'm trying to create generic component. Where view can have list of items and minimum that could be shown will be two and there should be a button with 3 more options and click on should expand the view and auto adjust with the container using auto layout. Can any one help me giving brief idea how do I implement this? would be really help full.
Image and Component that I'm trying to implement is as below:
You will use UITableView with 2 UICustomCell one for default view like your image and another for expand view, use NSMutableArray to save flag value that decide to use the first cell or second cell, and in UIButton action reset this array and reload your UITableView.
I hope I help you.
1) If I right understand, the flexible solution it's creating UITableViewCell and UICollectionView as one of subviews (another - UIImageView). UICollectionView has two kinds of cells:
Cell with label - item.
Show more button.
Each time when you press Show more button just can reload UICollectionView without restrictions or insert new items.
But in this case you should manually calculate tableview's height. Implement sizeThatFits in UITableViewCell.
2) Also can add UIStackView and use it for your goal but UIStackView has bad performance.
Hope it helps you!

TableView and CollectionView in the same ViewController with Swift

I'm building my application with Swift and I want to set up TableView and CollectionView in the same ViewController.
The only answer I founded is to setup my CollectionView in the TableViewCell of the TableView.
I did it but it scrolls separately.
The solution I found is to disable CollectionView scrolling and then configure CollectionView's height constraint programmatically by summing heights of the cells. It isn't perfect at all because cells become non reusable (250+).
I'm in desperation because I have seen this setup in many other apps and I think that answer is so simple but I can not find it anywhere.
Can anyone please help me? Thank you a lot!
Another option is to set it up as a single collection view with two sections, one that looks and lays out as a tableview and the other that has the more collection view appearance.
Or set it up as a single table view with two sections, one of which displays two side-by-side images per line (this is the old school way of creating this layout.)
Lots of ways to go about it, depending on what you want to play with and what you want to learn :)
You can put a UITableView and UICollectionView inside a UIViewController, and implement UITableViewDelegate, UITableViewDataSource and UICollectionViewDataSource.
Keys:
Use AutoLayout to make sure tableView has only two rows, and
collectionView takes the rest of area.
Make sure tableView.scrollEnabled = false
Here is a sample, https://www.dropbox.com/s/v6yc40udfk8mqx5/FlexTableCellHeight.zip?dl=0
Set up a blank ViewController. Then place two ContainmentViewControllers inside of the ViewController. Size them however you want based on how much screen you want to the be tableview and how much you want to be collectionview. Then create segues from each containmentViewController to your tableviewcontroller and collectionviewcontroller using embed. This will allow both to be on screen at once and scroll separately.
If you do not need to use a TableViewController and can get away with just a tableview you can also just place one containmentviewcontroller below your tableview and create the embed segue to your collectionviewcontroller.

height for row at index path not working with custom tableviewcell

i am coding and ran into a problem. I want spacing between cells and spacing on the side. i tried heightForRowAtIndexPath:but got spacing on the main controller not between cells! I basically want fake margin between a custom nib UITableViewCell but could not find anything legible in swift on google, I Do not know objective C and would like to do this in swift. could someone tell me what i am doing wrong and how they would fix in in swift? thanks!
Hi your problem is logical so for swift and objective c solution would be same.
as you say u r using custom tableviewcell nib u can create this view with marginal space in nib file like
here blue color part is UIView you can add your cell component like label,textfield add here and yellow part is space that you want between cells now load this custom cell .nib in your table with table delegate method you will get the out put way you want.
here you heightForRowAtIndexPath that is use for whole row
hope this will give you idea how to get space
You have to create the inner content view to hold all the subviews. Then leave the margin between the inner content view and TableviewCell's content view.

Can I put 2 UITextFields in the same tableViewCell?

Check out this image below, this is what I'm trying to accomplish, but I ran into some problems. The first approach I made was to have an imageView (blue square) and 2 separate tableViews within a scrollView. Each tableViewCell would have textFields inside them. The first issue was when the keyboard came into the view, I would move the view up to make sure the bottom textFields were not covered up. I then wanted to be able to scroll up and down so I could still see the top textFields as well. This didn't work because when I nested the tableView inside the scrollView, The scrollView wouldn't scroll. I was also having a problem with setting the firstResponder to pass from textField to textField on the second table only.
I then decided it would be better to create 1 tableView, and add a custom cell to hold my imageView and two textFields. My question is, is it possible to create that custom cell that will hold my imageView and two textFields? would this be a better approach?
Thanks
Wow, I think your can do it easily by UITableView. All you need to do is customising UITableViewCell.
This is possible using subviews. However, why you aren't considering UIViewController or UIScrollViewController for this design?

UISegmentedControl with UITableView

I have the following views set up in IB for my project: UITabBarView->UINavigationView->MyCustomViewController.
I added a UISegmentedControl and a UITableView to the CustomView via IB by just dragging them onto the screen. I would like my app to look very similar to the AppStore app. Everything looks fine in IB; however, once it populates the UITableView with data, it covers the whole underlying view with a single cell (the segmented control is covered).
I didn't want to have to do everything in code so I've tried to stick with IB since this seems simple enough. Does anyone know why my UITableView is taking up the whole frame?
I figured out what was going on. I was incorrectly re-sizing the table view cell when binding the data. I ended up using the new prototype cells in the storyboard instead of trying to create a separate nib.

Resources