Subclassing UITableViewCell only works for some StaticTableView cells? - ios

I have a Static Tableview with multiple cells. I have created a file subclassing UITableview cell which I then go on storyboards and add is a the class for the cells.
The issue is only one of the many cells work when I go on storyboard and add it as a class?
Why is this happening?

Related

How to make a reusable view cells for UITableViewCell and UICollectionViewCell ? I've tried to sublassing UIView for the cell but it's not working

I want to reuse my UITableViewCell to my UICollectionViewCell.
Until now, I always use 2 xibs, 1 for UITableViewCell and 1 for UICollectionViewCell and I think it's kinda waste.
I've tried to subclassing UIView for the cell but it's not working.
A way to do this is by using reusable views. Here is a Github project that can help: NibDesignable
You can also do this without using the project I mentioned, but it does make it easier. You then create a UIView with a View nib and put all your UI into this as well as any code for setting the UI components. Then you create your UITableViewCell and UICollectionViewCell and then just use the view that you created. You can also use prototype cells in a Storyboard for CollectionView or TableView if you prefer.

Uitableview with UICollectionviewcell and UITableviewcell

i need to create below design
I am following this code to draw simple collection view with horizontal scroll inside a UITableView
Current sample code work like this
UITableView-> UICollectionViewCell as cell with horizontal scroll
What i want
i want : First row with UICollectionview with horizontal scroll and
Then rest row with Normal UITableviewCell to show data
How can i do it .
add a UITableView to your view controller and implement it's delegate and datasource methods .(You can use UITableViewController instead of UIViewController).
for the fist cell of the first section in your tableview, you should use a custom tableview cell.
Inside this custom tableview cell, you have to add your collection view with horizontal scroll, and implement its delegate and data source methods inside your custom tableview cell class.
these are the steps you have to do.
refer this implement uicollectionview inside uitableview question for more.
Hope this will help to you.
You should design a UITableViewCell which has a UICollectionView inside, and set this cell for the cell in section A and for Section B, you should design a new UITableview cell.
When tableview's cellForRowAtIndexPath call you can check for First section and when first section load you can create new UICollection view object load in first cell. Than next section will load you can work as normal tableview work.
Not- you need to implement UICollectionview delegate and datasource methods also.

Use the same cell type in different screens in storyboard without duplication

I have a UITableViewController using many different types of cells.
In the code, each of those cells has its own UITableViewCell subclass.
In storyboard, they are all in the same screen.
Now I need to use the same cells in other screens as well.
How do I do that without having to copy and paste my cell in storyboard in the new screens?
I don't want any duplication in storyboard when it comes to layout and constraints.
Your best option is probably to move the cells into separate XIB files. You need to use the registerNib: method on UITableView to tell the table where it can find the cell definition.
You can create a
UITableViewCell
class.
Use this class as the cell's custom class and Ctrl link your cell's items to the property in this class.
Then you can use this cell class for other table views

UITableView within Subclassed UIView

I have a UIView that I subclassed to use as a slideout menu. Prior to trying to implement a tableview, I had programmatically added buttons with images and titles. It worked fine.
Currently I'm working with a subclassed UIView with a UITableView on top. I have a subclassed UITableViewCell and both subclasses have xibs.
The problem is that I can't seem to figure out how to have the tableview show up. I have the delegate methods in place as well as setting the tableviewcell as the dequeued cell.
The question I would like to figure out is how to get the tableview to show up. The background of the menu shows up but no tableview on top. Thanks for the help.

Using a Custom UITableViewCell with Prototype Cells

For reference, this tutorial I am following: http://mobile.tutsplus.com/tutorials/iphone/customizing-uitableview-cell/
I have to create a custom UITableViewCell, and from the tutorial, it said to leverage Prototyping cells and subclass UITableViewCell. Then connect the UI elements in the prototype cel to the custom class (of UITableViewCell).
The problem I am running into here is, there is only one cell for the whole table view that is displaying data. However, I am able to click on empty cells in the background behind that one cell that contains data. If i scroll up or down, cellForRowAtIndexPath is called and another cell gets displayed. However its only displaying once cell at a time for the whole table view.
Does anyone know what the problem could be here? Any help is appreciated, thanks!
Figured out what the problem is, my labels (that are supposed to be inside the custom prototyping cell) were added to the parent view and not the content view of UITableViewCell. This is because my prototype cell did not have a content view for some reason. I had to add a another prototype cell and delete the previous one.
reference: How to add subviews to a custom UITableViewCell in a storyboard

Resources