Two UICollectionView inside UITableView not UITableViewCell - swift

I found this post here : http://ashfurrow.com/blog/putting-a-uicollectionview-in-a-uitableviewcell/
But,unfortunately,this doesn't meet my requirement.It was here.
My flow is similar to the one at App Store.But,What I am gonna do was implementing pull to refresh and pull up to load more at top and button of UITableView.
I can include both two UICollectionView at the UITableView.But,I can't resize second UICollectionView as the data included in its datasource.
Please take a look
As you can see there was 5 blue block at second uicollection view.But,they are not showing properly.Its there anyway that i can fix my collection view data by resizing uicollectionview?
Because second collection view data will be dynamic as soon as I implement pull to load more below at uitableview cell.So,i disable the second collectionview vertical scrolling.But,I want to appear all the items at second collectionview.
Any Help?I can provide sample if needed.Thanks.

Related

2 CollectionView inside the TableView Cell not working

I'm working on ui that has basically two categories first is categories and second one is products when user click on any category the products load accordingly.Category showing in horizontal direction and products showing in vertical direction.I'm using tableView and inside the tableView cell I'm using two collectionViews.All outlets are connected when I running code (could not dequeue a view of kind: UICollectionElementKindCell with identifier CategoiresCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard") occurs.Also I'm using tableView height method I' want dynamically calculated and also in collectionView I'm using sizeForItemAt for calculating the height so how I can calculate the dynamically height accordingly to content in tableView as well as in collectionView according to tableViewcell.
I want this layout
My code pics
Error:
We have had the had the same problem with sizing of TableViewCell and dealing with accessibility large font and collection views, the way we got around that was to get the table view cells to to relayout there contents a second time, it seem like the cell needs to layout there subview again with something like layoutIfNeeded, it was a work project, so I don't have access to anymore and can only go by memory, but hopefully this will point you in the right direction.

Creating tableview cell content programmatically

I want to create UItableViewCell ui programmatically based on API response.
I'm using a API that output a set of articles, but the content of these articles could be deferent, for example some articles may not have a description, or some of them may not have a image. I want to create Tableview cells programmatically based on these data.
I have tried setting constraints in viewDidLoad method of the cell but It does not work.
Do you have any suggestions on how to do this?
Depending on how different the articles are from each other, you could either choose to design multiple different kinds of cells for your table view and choose which cell to use for a given row based on the data you have, or you could design a single cell that uses a stack view to hide the labels that you don't have data for. When you set a view inside a stack view to isHidden = true then the stack view will resize its subviews as if the hidden view does not exist.

How to enable Horizontal paging for each Section in UITableView

I was using an app the other day which appeared to separate its UITableView sections (events for each day of the month) into separate PageViews. Here is a gif of the functionality: https://giphy.com/gifs/3ohBV4yNhpYOFoURxe.
When I tried using a page view to accomplish this it seemed that you could only use separate ViewControllers for each page, rather than different sections.
Any idea on how one would go about doing this? I’m at a loss.
You can do that by using a collectionView as reusable tableView cell, which means, sections and cells from your tableView can be a collectionView. And then you set your collectionView cells as big as the example.
If you would like to do this in one UI element, use UICollectionView.
UITableView appearing and interactions are very limited.
this could be a good starting point:
https://www.raywenderlich.com/156794/custom-uicollectionviewlayout-tutorial-parallax

Newbie TableView challenges

I am building an app that requires a tableview control so that users can select multiple rows and act upon them in some way. I find it easy to load my data and display it using the UITableViewController but it seems when I do it this way I am unable to place any other controls on the page, such as a toolbar to give the user some actions to perform on the selected rows. I can place a toolbar control on the form in the storyboard, but it doesn't render in the emulator.
Using a UIViewController and placing a TableView on it seems to come with its own set of confusing challenges (that will make total sense once I conquer them).
Is there any advice for a smooth way of getting a table view with toolbar controls? Thanks!
don't use a TableViewController. Use a Standard ViewController, then add a UITableView to it, and adjust the size. This way you will be able to do whatever else you want on that view without limiting yourself to the tableView only functionality.
When you do this make sure you add the datasource and delegate to the connected table. Then add cellForRowAtIndex, number of sections, number of rows, and whatever other delegate methods you need for your table.
Good luck
Is there any advice for a smooth way of getting a table view with toolbar controls?
Yes there are few ways to accomplish this, one way would be adding a footerview to your tableviewcontroller check these
http://developer.apple.com/
UIButtons on tableFooterView not responding to events
Easier way to add this is using storyboard.
Just drag and drop a view in to your tableviewcontroller, then you can adjust the views size and put anything from objects menu to inside of the view.
Now the problem with that is view will not be stable position at the bottom of the page like a tabbar. Lets say you have only 1 row in your tableview, footer view will go up just below that 1 row, lets say you have hundreds of items in your tableview toolbar will be at the bottom of the rows.
The other solutions for your problem would be either create a custom view and adding it to current view or window (this is little bit adbance),but if you want this just google it.
Or just as you said, create a viewcontroller and put a uitableview inside. Dont forget to add <UITableViewDelegate,UITableViewDataSource> to your .h file and then you can call UItableview delegate methods.\
Good Luck.

Only update visible table view cells?

I'm trying to load a table view with cells that contain images downloaded off the internet. I'd like to only perform the download operation on cells that are currently visible instead of downloading every image as the user scrolls down quickly.
I found the indexPathsForVisibleRows method and that should fit my needs nicely but I need a way to figure out when the table view is no longer scrolling. My idea is to use the indexPathsForVisibleRows when the table view isn't scrolling so that all of the images currently on screen are loaded without unnecessarily loading images.
Are there any methods that I can override or notifications to subscribe to that will alert me when the table view is no longer scrolling?
Thanks!
Take a look at the methods listed here:
http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIScrollViewDelegate_Protocol/Reference/UIScrollViewDelegate.html
If your view controller is the delegate of the UITableView, these will also be fired for it, as the UITableView is a subclass of UIScrollView.
Particularly, pay attention to: scrollViewDidEndDecelerating. This is the one I used to do pretty much what you're asking.