Using UISwitch/UIButtons in views initialized by closures
READ ME FIRST: Just putting this edit in here in case someone Google searches this: My problem, as suggested by /u/frogbubbles, was AutoLayout constraints. In my case I am using PureLayout and did not have a bottom constraint.
Therefore, everything below is actually quite misleading. That being said I don't want to delete the post in case it helps someone.
////////////////////
Hi everyone,
I'm newer to Swift, and the way I learned to do programmatic views was along these lines:
let myView:UIVIew = { let myView = UIView() //some code return myView }()
Everything was going great with that method until I tried to add something that required user interaction (in my case a UISwitch). I can't get it to do anything (touching it does nothing). I've Googled the problem up and down but I'm having a hard time understanding why it won't work, and what I should do to make it work.
Any advice or help is appreciated. Thanks very much.