iosuitableviewstaticaccessoryview

Why doesn't my UISwitch appear in a static UITableViewCell?


I'm creating a settings screen and can't a UISwitch to appear in one of the cells. I've been struggling with this for hours, combed Apple's Table Views tutorial, and read probably 20 Stack Overflow threads.

I'm using static cells because the content won't change, the cell that I'm putting the UISwitch in is a custom cell, I've created an @IBOutlet to it in my UITableViewController but when I run it, there's no UISwitch.

Here's the setup in the storyboard

Here's the setup in the storyboard

and here's what I get in the simulator: enter image description here

The Apple tutorial mentions a configureView method but it's in Obj-C and I didn't find an equivalent in Xcode.

What else should I be looking at or doing to fix this? Thanks.


Solution

  • I don't see any constraints in your document outline. My guess is that the switch exists but is off the right edge of your screen, because there are no constraints to keep it positioned where you want it.