Collectionview cell with both direction - swift

I have collectionview with horizontal flowlayout direction and size of a UICollectionviewcell is screen size. Is it possible to scroll vertical if content of cell exceeds the screen size height?

Yes you can. I think, iPhone Youtube app is created in the same fashion!! :)
You can create a CollectionView controller with its collection view set to horizontal scrolling, set the collectionView cell size to the screen size. And set the paging enabled property of collection view to
true.
THis will allow you to scroll horizontally as if each cell was a page itself.
Next up, you can add another collection view to each of these cells, with vertical scrolling property of this collection view.
THis can be achieved very easily by subClassing UICollectionViewCell of the CollectionViewController. In the subclass, each cell must have a UICollectionView property.
Remember that the UICollectionView in each cell will have to have delegate and datasource set up properly.
This is exactly what you are looking for.
Source of all information is within this link just above. Hope this helps

Related

UIView with CollectionView and TableView in Swift

I have a UiView that contains a CollectionView for images of a kind of products and a TableView that contains cells with images and labels of another kind of products.
What I'm trying to do is give this UIView a scroll, showing of the images of the first CollectionView unfolded, and scrolling down show all the TableViewCells unfolded, not with his own scroll in their section.
I have tried embedding the two sections into a scrollView but this doesn't worked.
What could I do?
Any reason why you picked a UIView instead of a UIScrollView? Seems like a scrollview would solve your problem.

Display table cell in a scrollview and scroll to the next or previous in swift

I have a table view with cells, when I select a cell it displays in another view and shows detailed information. Rather than using swipe gesture, how can I lazy load 3 details cells in a scrollView when the scrollview scrolls. ScrollView scrolling is more seamless.
You can use a Horizontal UICollectionView to display your cells details, you need to pass the entire array of elements to your new details viewcontroller and then scroll the collectionview to the indexpath selected.
here you can find an example of how to create a Horizontal UICollectionview
https://medium.com/#shaibalassiano/tutorial-horizontal-uicollectionview-with-paging-9421b479ee94

Implementing a dynamic height on UITableView

I have a UITableView embedded in a UIViewController. The TableViewCells are rows for the user to select something, so when they touch it a checkmark appears, heres where my question comes in:
I dont want the UITableView to scroll in its window, I want the TableView to grow with the items it contains. Do I need to put a scroll view on the UIViewController and then the TableView on that? Or will the ViewController scroll if the content is bigger than the View?
Also, Im not even sure where to start with changing the height dynamically of the UITableView, everywhere I look its about changing the cell heighets dynamically.
Please Help! Thank you!
self.tableView.scrollEnabled=false;
stops the scrolling
self.tableView.frame=CGRectMake(0, 0, (float)width, (float)height);
sets the size of your tableview
But I don't understand why you want to stop tableview scrolling and to scroll the whole view....

Custom cell in UITableView

I am making a custom cell which has text fields and as a result the custom cell is greater than the size of the iphone screen.But i am not being able to do horizontal scroll to reach the end of the cell.
I have tried using viewController and adding table view to it as well as creating table view controller and adding custom cell to it.
when doing it through TableViewController,I am not able to horizontally scroll it,whereas i am not getting how to add Custom cell class to the tableView object placed in viewController.I know that UITableView is a subclass of UIScrollView but not able to implement it.Please help.
Thanks
as per the documentation at
A table view in the UIKit framework is limited to a single column
because it is designed for a device with a small screen. UITableView
is a subclass of UIScrollView, which allows users to scroll through
the table, although UITableView allows vertical scrolling only.
so as desired in your case you will have to take some other approach. Now using Custom cell with TextFields should not actually need you to require Horizonatl scrolling. If the text is really large you would like to consider using TextView instead of TextFields.
Hope it helps
Ideally, you should be truncating your text. But if it is important for you to display the entire text, add a scroll view as a subview (or set it as the content view) and add your labels to the subview. Each cell will then be individually horizontally scrollable.

A UITableView followed by several buttons- any way to size the table view to fit a variable number of rows?

In Interface Builder, you have to set the size of the tableview and position the other elements beneath that. I want the tableview to be sized to fit any number of rows and the buttons to be moved down relative to the tableview.
Is it possible to do this without building the whole thing programmatically?
You should embed the buttons within a UIView, and set that UIView as the tableFooterView of the UITableView. You can do this in IB by dragging the view into the bottom of the UITableView. This way the buttons will always be below the last row of the tableview, though I should warn you that if there are more rows than fit on-screen, the buttons won't be visible until you scroll down. If this isn't what you want, then you'll need to do something more complicated (namely, run -layoutSubviews on the UITableView, then ask it for the rect of the last section, and use that to calculate where the buttons should go).