How to build this layout in Swift - ios

I'm working on an app that has one page where it should be an image at the top and then a table underneath it. The thing is that when I scroll, I want everything to scroll, including the image. What is the best approach for this:
a scrollview with an image view and a table view ?
create some kind of static cell in the tableview for the image?
Does anyone know some examples?
Any help is appreciated!

Best way is to use a UITableViewController. With that you can implement all the cells easily and efficiency. Then drag and drop an imageView on top of the tableView in the UITableViewController. You can place it right between the tableView and the Top to get what you want.

Related

ioS Scroll View with dynamic table View

I want to create a “ViewController” Scene with a “Scroll View” and in this view there should be a “Table View” at the top, 1 “segmented Control and 2 tables at the bottom.
The “Segmented Control” should switch the bottom table views.
Like in this picture:
My problem with this scene is that the table should have a dynamic height.
I need the bar over the complete page and not in the individual tables.
Is it possible to create such a scene and if yes, which constraints do I have to set?
I hope you can help me! Thanks a bunch!
tableView inside scrollView is a disastrous idea, because
tableView itself have its own scrollView.
Scrolling will be very sticky and it may freeze UI.
The best solution comes on my mind is to take single tableView and manage multiple sections.
The Green portion will be your first section.
Segment control will be second.
and blue section will be third.
In this way you can achieve both dynamic height as well as single scroll bar condition.
Let me know if it works.

UIPageViewController with a Table View, inside an UITableView

I want to replicate this sort of UX, like in the product hunt app
I want a few scroll pages inside a tableview
I tried to replicate creating a tableview with some static cell and a cell with a container view inside that is referred to a page controller, but I have a lot of problems adjusting frames
Do you have some advices or more straightforward methods to replicate this ux?
Imagur Link to the Gif of the UX
You can achieve this effect with the help of these two libraries.
For Parralax TableView header :
https://github.com/Vinodh-G/ParallaxTableViewHeader
For horizontal scroll effect:
https://www.cocoacontrols.com/controls/instagram-feed-view

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.

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?

Resources