How can I add a tableViewCell within another TableViewCell? - ios

I need to implement a cell inside of another cell, is it possible in any way? Or should I just find another way? thanks
Edit:
Sorry for the brief description, the problem here is that I've got a component thats a cell, and I want to include it in a tableview with some other icons and labels in the cell. Maybe the best solution here would be to include a tableview inside of the cells, with a unique cell in it, as someone suggested. I've tried to do it and it worked but when it came to launch another screen when selecting the cell it only worked on the margin where the inside tableview isn't included, how could this be solved?
something like this
Thanks!

Find another way. I don't know what exactly you want to do, but maybe modify the headerView for your section (kind of like a cell) and use the cells within that section as your sub-cells.

As it’s been stated above, I would strongly suggest finding another way. Without knowing more details about what exactly it is you’re trying to accomplish, it’s hard to give you another solution but I ran into something similar last year. It’s gets extremely messy and it does not scale well, especially when using a lot of dynamic data. Also, when using UIKit, I think there is a limitation of having a dynamic table cell inside another table cell, which limits your use cases dramatically. If you provide some more details on what it is you’re trying to accomplish, perhaps we can point you towards a better solution.

Related

What is the best way to make a data grid in swift?

example
Good evening everyone!
Part of my requirements for the app I am building has me creating a data grid similar to the example linked. I have spent the entire day searching google and this site in order to find the best way to get started in swift. I have read so far that both a table view and a collection view could work, but that a collection view is preferred. My data grid doesn't necessarily have to be scrollable but the data does need to be editable. I don't have much experience using either tableviews or collectionviews and I'm looking for the simplest implementation without relying on a third party dependency. Any help or direction is greatly appreciated.
Since I don't know your experience level, I will explain at a basic level - my apologies in advance if it's too basic :) A UITableView displays rows of data, while a UICollectionView displays cells in a grid.
So, at first, a UICollectionView might appear to be the better option. But as always, things get complicated pretty quickly :) For example, are you going to implement your UICollectionView as one cell for the whole row, or are you going to implement a cell per column in your table of data? And if you implement cells per column of data, how are you going to handle the different types of cells you might (or might not) need for each column?
There are multiple decisions that might need to be made, and only you know the answers to a lot of these :)
But the simpler option probably is to go with UITableView and that's what I'd suggest if you are new to both UITableViews and UICollectionView. Try out a UITableView-based approach first and if that doesn't work, or you see limitations, then try a UICollectionView. The experience you had in building the UITableView will help you in moving on to UICollectionView anyway :)

Size Agnostic UICollectionView//UIScrollView

I am trying to figure out if there's a way to create something like a UICollectionView for an arbitrary and potentially infinite amount of UICollectionViewCells. I also want to be able to do fancy things with my own UICollectionViewLayout.
What I'm trying to do is create a dataSource that's a linked-list. So each element in the dataSource knows which element comes before and after it. I have no idea how big the list is. I don't care.
I've looked at the UITableView stuff and it needs to know how many elements are in it. I've looked at the UICollectionView stuff and it ALSO needs to know how many elements are in it. The UICollectionViewLayout needs to know how big the view needs to be (collectionViewContentSize). All of this is frustrating to me because I don't see why this much detail is needed.
For simplicities sake, lets assume that I only need to show ONE cell at a time. I don't see why I can't just tell the View that it's only 3-cells wide (always) and when you scroll to the left or right, pop the cell of the long side and put it on the short side? At no point will I need to be able to say "scroll to 5" I just want to be able to say "next, next, next" or "prev, prev, prev"
What's the best way to capture this behavior?
The best answer I can think of thus far is to basically do what I said w/ the "use three cells" thing. I could just have a CollectionView that is concerned with how to best lay out some n-cells (where n is 3, or 5, or 25, or somethign) and some other thing that is concerned with what to be putting in each cell and while the view is cycling between the same n cells, the data thing is pushing the appropriate data into them?

Implementing chat layout with UICollectionView with AutoLayout

Is what I'm trying to accomplish here even possible? I've been searching for hours for sample code and/or SO answers that demonstrate this simply enough to follow, but so far no luck.
Goal: implement something that looks roughly like this mock:
Yes, I know this is easy with a tableview, but the full design includes custom interactions, multiple columns, UIKit dynamics, and custom animations when adding/deleting cells, so UICollectionView is the better candidate. Until I can get this core layout to work, though, the rest of it is just a pipe dream.
So far I've started with a subclass of UICollectionViewCell that has a single label with constraints to all 4 sides of the content view. At which point I run into these issues:
It's unclear how I can calculate collectionViewContentSize() when the cells don't exist yet, esp. given that the majority of cells are actually offscreen most of the time!
If I just throw in an arbitrary content size (e.g., 320x1000), my views show up, but their heights don't adjust to the label content…I can't seem to read the cell height from within my UICollectionViewLayout subclass.
Seen or done anything like this? I'd include code, but after hours of futzing with it. I'm just looking for a clearer tutorial or sample code that fits this scenario.
There's a project you might want to look at. It's fairly involved and probably has a lot of code for situations that don't quite match yours, but does indeed create a chat view using a UICollectionView.
It can be found here:
https://github.com/jessesquires/JSQMessagesViewController
For item 1 - with regards to calculating collectionViewContentSize, I think you'll find you may not need to calculate that, at least as long as you're using a UICollectionViewFlowLayout subclass for the layout.
And for item 2 - rather than set a fixed 320x1000 take a look at the JSQMessagesCollectionViewFlowLayout.m for sizeItemAtIndexPath.
Sorry, this probably should have been a comment, but I lack the reputation to comment & so I made it an answer (doesn't that seem backwards? Ah well.)

Parse PFTableViewController vs regular UITableView with PFObject as data source

I am new to iOS development, and I have been doing a fair amount of research. Unfortunately, as the title of my post suggests, neither possibility seems exactly suited to my needs.
I need a lot of customization with respect to the look and feel of each individual table view cell, and I need for my table to have header sections which are clickable. I would actually like for the section headers to have the drill down quality and not the cells beneath each section header.
To my knowledge, the problem with PFTableViewController is that it doesn't easily allow for multiple sections (even less so if I need for these section headers to be clickable and of a different look and feel from the regular cells.) Furthermore, customizing the PFTableViewCells doesn't seem terribly simple either.
However, if I use the regular UITableView even with Parse as my backend, won't I run into some difficulties with respect to loading, pagination, etc...?
I have a pretty good idea of how I would implement this app with regular UITableViews so I guess here is my question: is it worth it for me to try and figure out all of this PFTableViewController stuff?
I should also mention the fact that my table view controller will not take up the entire view but only half of the screen.
Thanks in advance for any and all advice
It seems that a normal UITableView will suit your needs. If you want to customize the look and feel of individual cells, you can just subclass a UITableViewCell and modify it.
In terms of your needs with the headers, it's hard to say without knowing more about your app, but you want to follow standard user interface conventions. Users don't expect headers to be clickable. Instead, they attempt to traverse information hierarchies by selecting table view cells, which then bring them to new views with more information. Based on your, needs I think that a standard table view controller with some customization is what you want.

How to make more use of the separator line? E.g. making it a cell?

I was wondering, how you could do something like this, e.g. make the separator line usable, in this example as a display of votes. I think the separator line is a cell here. When you click on it a popover menu comes and you can click what you want to vote for. My question is: Does someone know how to do that or has a link to a useful explanation?
I don't think that the "seperators" are actual cells, but rather part of the previous cell. You can see that the indicatorview is seemingly not centered vertically (which I personally even find sloppy).
So, just make a custom cell with your desired behavior. Maybe google for "Accordeon cell" or something like that, I think I remember they talked about cells like that in the previous WWDCs.

Resources