UICollectionView/UITableView Universal App - ios

I have iPhone app, which using UITableView with custom cells. I try to create universal app, and i understood that I need multiple columns for content. I thought that UICollectionView with custom cells will be the best idea, but I don't know how to combine UICollectionView and UITableView in one ViewController.
Maybe are there any possible variants to use different classes for iPad and iPhone?
Can anybody help me with it, or give any advice?

Use UITableView or UICollectionView.
But you won't need both in same viewcontroller as I known.
As you said, To show multiple columns UICollectionView is good to go. UICollectionView does all things which is doing by UITableView. Even you can do much more things with UICollectionView.
You can simply even create your own layout. Or else there is a default flow layout.

Related

Looking for the best scroll-view solution

I want to learn and implement the most suitable/simple solution to display dynamic data (JSON) in three lines and an active (clickable) download icon. Screenshot is attached
I would be glad to get your ideas and advice!
Thanks
UITableView is the way to go, as you can reuse a custom cell you define. And to add to that, UITableView's cells are loaded lazily and are reused. You can use a UIScrollView but if you have a lot of rows it can horde your memory real fast. In your case, a UIScrollView can be used as well, but if you plan on expanding, UITableViews would be the choice. All in all, go with a UITableView + a custom UITableViewCell
If you have array of data like this, the best way is using UITableView class. With UITableview, you can custom your UITableViewCell on the fly

How i can use multiple nib files with multiple arrays?

I am creating my iOS app, and i during that , now i have to build scrollable screen where there is image view, labels, collection view, Reviews etc (Prototype Image is attached). I am wondering is it possible to make that type of screen with UITable view using multiple Nib files? (If it is possible, kindly guide me as how i should use multiple Nib files with multiple arrays). And , if it is not possible, how else i can go for it? Kindly guide me, and sorry if thats a duplicate because i have searched but i was not able to find any good answer.
There are several approaches that you can do.
If you want to use UItableview, then you need to create multiple
UITableviewCells, where each cells is based on the section of the design. Then you can load it by using array, as you logic stated above. For example indexpath[0] you'll load the cell with the picture(lets call this pictureCell), then indexpath[1] you'll load descriptionCell, and so on.
The other approach is using Scrollview, with several UIViews on a vertical stackview. And then you'll create a UIView Subclass based on the section of the design. This is usually my go to solution.
I'm not sure what "array" is refering to here, but by the look of your screenshot, I would go with a StackView inside a UIScrollView, or something like that. No need for a UITableView if you don't have a repeting pattern, you can just stack multiple views in a scroll view.
I hope it's clear enough.

UITableView vs UICollectionView vs UIScrollView?

When should I use which, and what are the disadvantages or disadvantages of each? I'm mainly confused with scrollview vs collectionview, I know tableview is limited to one column (I heard it gets messy when more than one column), but scrollview difference with collectionview seem the same to me.
Both CollectionView & TableView are basically subclasses of UIScrollView.But as compared to UIScrollView here you are provided with proper methods to provide your dataSource & delegates to handle operations user performs on data. Along with this you are provided predefined layout classes.
Now to choose between them completely depends on your UI Requirements. Suppose you want to display just a list of items with a simple UI go with TableView.If you want a custom Layout like a grid or like the one you see in Apple's photo's app CollectionView is the choice.
if you have a complex UI & you have no idea about Custom CollectionView layout classes go with scrollView.
Consider UITableView and UICollectionView first and if you cannot achieve the effect you want with them, try UIScrollView then. UIScrollView is more basic class. UITableView and UICollectionView have more delegate method for us.
If you want a list,UITableView would be better. And if you want a multicolumn,use UICollectionView.

Using TableView instead of ScrollView

For creating a login page or something like that, in autolayout case I use tableView instead of using a scrollView in viewController. For IndexPath majority cases I reuse the customCell. For entirely different items only I use another customCell. Since the Cell Class are increasing in my project. I dont know is it a good practice. Please share your opinion to increase the overall performance and least memory usage for my application.
Putting UITableView in all views is not a good practice every time.
I recommend using scrollviews and content views inside them in pages like login.
Use Tableviews only in those screens which show repeated contents.
I have seen codes generated through tableview controllers in every page.
I dont do in that way.
Better you go for Scrollviews.. Its a good method as far as I have seen.

How to reuse UIViews, the way UITableView does?

I want to create a view that shows vast amounts of data. Using UITableView would have been a good idea except it's not the way/style I want to show it. I'm thinking of creating my own view, and I was wondering: UITableViewCell is constantly being reused through the dequeueReusableCellWithIdentifier method; how does this work? I mean, I can figure out how to cache UIViews, but how does UITableView draws them on the table, allowing them to still be interactive, without keeping the UIViews themselves?
Thanks!
Aviad.
Apple's ScrollViewSuite sample code shows how to create a tiled UIScrollView that reuses views very much like a table view. You could use it as a model or starting point.

Resources