XCode TableViewCell can not see views in editor

I put some text and images in this views, when put one or two views is ok, but all views is gone when i put over five views. The last image is result view. Is it because the cell has a limited length?

Answered by Claude31 in 700746022

Finally, i use single cell prototype, but i really want to know why.

Does it work now ? If so, you can close the thread on the correct answer.

I do not understand exactly what problem you had. But the principle of TableView is to have cells which are similar in design with content that depend on the data defined in the dataSource (usually an array of some struct that contain all texts, references to images, button state…).

You should not define the content of cells in IB for each cell, but do it in

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

where you populate the cell content with the data from dataSource.

If you have cells which have different design, you create several prototypes and select which to dequeue in cellForRowAt before populating.

Hope that helps. If not clear yet, please show the code of tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath)

Is it because the cell has a limited length?

No, there is not such limitation.

Screen indicates you have an error and that editing may be limited.

  • Clean Build Folder
  • Quit Xcode
  • Restart Mac
  • Open project

and tell if that works.

Looking at the nib image, it seems you include several similar cell prototypes. And app display confirms they are very similar, except of course for the content of each element in a cell (image, texts). Why do you do it this way ? Why not a single cell prototype ?

Accepted Answer

Finally, i use single cell prototype, but i really want to know why.

Does it work now ? If so, you can close the thread on the correct answer.

I do not understand exactly what problem you had. But the principle of TableView is to have cells which are similar in design with content that depend on the data defined in the dataSource (usually an array of some struct that contain all texts, references to images, button state…).

You should not define the content of cells in IB for each cell, but do it in

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

where you populate the cell content with the data from dataSource.

If you have cells which have different design, you create several prototypes and select which to dequeue in cellForRowAt before populating.

Hope that helps. If not clear yet, please show the code of tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath)

XCode TableViewCell can not see views in editor
 
 
Q