UITableViewCell's contents disappear when app run in simulator - ios

UITableViewCell shows up in Main.storyboard but doesn't show up in simulator.
I'm using Main.storyboard. In my simple experiment with Swift, I added a TableView, then put a UITableViewCell in it, and then I put an image and a label under the cell's content. It looks okay in Main.storyboard but when I run the project, the content disappear. All I did is purely on Main.storyboard and not touching the .swift file yet.
Here are the links of screenshots of my simple work:
How my app looks in Main.storyboard
How it looks when I run Xcode simulator on iPhone 8, the tableview cell's content disappear
I have searched the problem through the stackoverflow and found a related question here: 'UIImageView doesn't show up in simulator', then I followed the recommended solutions from the forum but still didn't solve the bug.
What I have done so far to solve the bug:
Check if every item in my view has four constraints defining X, Y position, width and height.
Try to check and uncheck the autolayout flag for my Main.storyboard
Make sure my tableview cell's contents (and everything inside my view) has alpha set to 1
Well I haven't check how things looks in my .xib file.
I would like to know if this is a bug, or just a problem in my settings?
I'm quite new to Xcode, swift, and iOS app. Any help or suggestion would be greatly appreciated. If you have the same problem with me, I would like to know your case as well.

The only reason your cell doesn't show up in the simulator is because your tableview is dynamic.
Dynamic table views have data that is loaded at runtime, where there isn't a fixed number of cells, and every cell has the same layout. The Apple tutorial is a good place to start. It guides you through on how to use a tableview/tableviewcontroller.
There is no way around it: You have to code in .swift files if you want to use dynamic table views.
If you are going to use static table views, on the other hand, the number of cells is fixed, and the data is not loaded at runtime. You can use static tableviews if you don't want anything to do with code at the moment.

I had a similar problem. I solved it by deleting constraints for the affected view and starting all over.

Related

Custom TableViewCell contents invisible on iOS9 (Xcode7)

since the upgrade to Xcode 7 & testing my app with iOS9, the contents of some custom cells have become invisible at runtime. There's an emphasis on 'some' here, as this affects only 2 out of 6 table views, all of which reside in different view controllers.
A similar problem was encountered here, but the answer ("check constraints") does not work for me:
Custom TableViewCell contents invisible on ios9 xcode7
The cell that makes trouble is a large placeholder that is displayed when no data is available to be presented in the table.
It only contains a UILabel which is centered by two constraints.
The cell, as well as other custom cells not shown in the picture, are visible at runtime. However, not their contents.
In other view controllers of the same app, the exact same custom cell (same design, same class, same reuse identifier...) work as they should.
However, not in this VC.
Before the upgrade to Xcode 7 and testing on iOS9, the cell's content was visible also in this VC.
I haven't changed anything in IB or the code and double-checked everything a couple times. It's crazy and I am desperately looking for help :-)
Thanks for your time
In the meantime I figured out the answer:
In iOS 8.4, the label is installed in the view hierarchy, whereas it isn't in iOS 9.2 according to XCode's view debugger.
The size class for the label is Regular/Regular, which should suffice for iPad.
When I add the size class Any/Any for the label, it will install correctly.
This is clearly a bug which has been confirmed to my by Apple, but not acted upon yet.

Cell content of a Table View that is part of UISplitView is not being rendered

Here is some background to the issue. I've been looking at it for the past two days and to my knowledge everything is properly configured. To make sure that we are on the same page with versions that are being used I am using the following:
Xcode 6.1
Code is in Swift with some added Objective-C libraries
OS X is 10.9.5
I have UISplitView that was added to the storyboard at a later stage of the project. The project was started form Single View template. Normally the left part consist of a UITableView. When Xcode added it to my storyboard it also had a prototype cell setup. I've added the needed Identifiers and now the prototype cell is accessible in my code. I've implemented and binded the needed delegate and dataSource protocols and checked that their methods are actually being called and working. I've also added background colors to the prototype cell and the prototype label and I see a cell when there should be one but it does not have a label. So here is a list what I've checked:
Data binding is working and data is available. I've also cross checked this with a second UITableView that is in the project and is working properly. This is also true because I see the background color that was set for the cell when I run the app and data is available;
The storyboard does not have any errors or warnings. In fact the project itself does not have any warnings on compilation;
I've reset/removed/recreated constraints multiple times;
I've used the Preview mode and I can see the label rendered properly on my target device and orientation. I've checked this because storyboard sizing can be easily overseen so that you actually don't have the label for this device and orientation but this is not the case;
I've used the new layout debug feature that Apple added in Xcode 6 called view debugger and it does not show a label for this cell. And on the following screen shot you can see that the background of the cell has been properly rendered but there is nothing that is on top of this cell. The cell has been selected for better clarity.
So pretty much I am out of ideas right now. Can you please help me on revealing this mystery?
To answer my own question.
I've created an empty master detail project and saw that this is working there. This made me think that actually there is some kind of a bug in Xcode when you drag and drop an UISplitViewController to your storyboard. For some reason the storyboard is not properly configured. I have no idea what is not properly configured but there is definitely something that is wrong.
Because of the above observations I deleted the UISPlitViewController and used a plain UIViewController to recreate a similar setup that will also work for me. As a result I was able to adjust my already existing code to the new View and use it without logic changes. Which to me just indicates that this is an Xcode issue.
Thanks!

Why don't my views show up in Storyboards and are greyed out in the left pane?

I am experiencing a weird bug in Storyboards.
I set up a UITableViewController with prototype cells and set some autolayout constraints. Everything fine until here.
Then, I had to move the whole project directory into another folder. This is a normal action I believe that shouldn't lead to any problems since the app and all the files are pretty much self-contained.
However, since I moved the project, the prototype cells in the UITableView are shown empty within my Storyboard, but the subviews are still showing up in the left pane where all the scenes and views are shown... Only that they are greyed out (see the screenshot)... Does anyone know what this means? I also looked into the XML of the Storyboard file, but everything seemed normal to me in there...
Any ideas?
EDIT: Strange thing also is that the IBOutlets from the custom classes still are set and link to the views in the storyboard... but only in the left pane, not in the storyboard itself.
Just found an answer myself, it was because Size Classes were reset after I moved the project...
Greying out views is Xcode's standard behaviour when the views are only set for a specific size class which is currently not selected!
I had set the size classes for my UIViewController to Compact - Any, this is what it looks like in proper state:
The problem occurs when I change the size classes to another one (e.g. Any - Any):
This happened to me because I copy and pasted some of my views from nib into storybaord. Turning size classes off, and turning it back on fixed the issue. This can be done in File inspector, using a checkbox named Use Size Classes

Xcode/iOS-Cannot edit content of Table View Cell...I'm using the storyboard editor

Hey guys this is my first question here on stackoverflow, but I've been browsing for quite some time.
I'm kind of new to iOS programming, but I feel like I'm getting the hang of it though.
I ran into this one issue today that just has me stuck though. I have a tableview with 8 prototype cells in it, and everything was working fine with them, then I realized I needed more cells. I add another cell, but then I found I couldn't resize the contents of the newly created cells. I don't think it's an issue with just my project because I just downloaded a tutorial that uses a tableview and I ran into the same issue.
Here are some pictures to show my issue: (I can't post images so here are the links)
Size inspector for one of the new cells:
What happens when I click on the label in one of the original cells:
What happens when I click on the label in one of the new cells:
Has anyone had this issue before?
What could it be?
Thanks!
![enter image description here][1]Got it, the cell you used is auto layout, do not check the auto layout in the xib or storyboard!
Interface Builder Document->Use Auto Layout Don't check it!

Custom UITableViewCell class in Xcode 4.2

I've been following this Apple Doc to add a custom UITableViewCell that I layed out in an .xib to my project. One problem with the doc is that it seems like it was written for an older version of Xcode.
I'm able to load my UITableViewController that the custom cells are on, but the cells are all blank. My custom cell contains several UILabels, and has a non-default background color. The table that appears when I run has the default white background and no labels. If I change the UITableView's View -> Background on my storyboard, the color of the cells' background changes, but the labels still don't appear.
Of interest is the fact that the data is still in my table's cells. The UITableViewController is itself called as a popover from another controller. When I select one of the cells, the strings from the various label.texts are supposed to be loaded into their own labels on the popover's delegate, and that code works fine (except when I try to include a UINavigationBar in my popover, but that's probably another issue entirely).
I'm still pretty new to iOS developement, so if there's anything I'm leaving out or being unclear about let me know.
Edit - cleaned up code, now is completely different question than when I originally posted, but is still on the same topic. Should I have deleted the old question and posted this as a new question all together, or is it alright that I just edited it?
I'm still not entirely sure what was wrong with what I was doing before, but I managed to get what I wanted. I originally dropped a UITableViewController onto my storyboard set up a popover segue (also on the storyboard) and tried to display the popover with performSegueWithIdentifier. Instead, I now create the popover completely in my code (which I found a nice tutorial for here on SO, by goggling "show popover programmaticly"), without having anything for it on my storyboard. That seems to be the most documented and stable way to show a popover. Once I displayed it that way, my custom cells showed up exactly like I wanted.

Resources