I have an UIButton located inside of an UIView subview. The view appears fine but the button is not responding to touch. The subviews are two separate ViewControllers embedded into the container views.
On the storyboard all views, controllers, and buttons have user interaction enabled. I have also enabled user interaction for the subviews programmatically.
Here is the code:
@IBOutlet var showtimeView: UIView!
@IBOutlet var reviewView: UIView!
var viewTwo: UIView!
var viewThree: UIView!
override func viewDidLoad() {
super.viewDidLoad()
viewTwo = ShowtimesView().view
showtimeView.addSubview(viewTwo)
viewThree = ReviewsView().view
reviewView.addSubview(viewThree)
showtimeView.isUserInteractionEnabled = true
reviewView.isUserInteractionEnabled = true
viewTwo.isUserInteractionEnabled = true
viewThree.isUserInteractionEnabled = true
}
@IBAction func segmentChange(_ sender: Any) {
switch(segment.selectedSegmentIndex) {
case 0:
detailsView.isHidden = false
showtimeView.isHidden = true
reviewView.isHidden = true
break
case 1:
detailsView.isHidden = true
showtimeView.isHidden = false
reviewView.isHidden = true
break
case 2:
detailsView.isHidden = true
showtimeView.isHidden = true
reviewView.isHidden = false
break
default:
break
}
}
What else could be preventing the UIButton located inside of the subview from responding to touch?
EDIT: I changed the color of the container to check if it was covering the viewcontroller. The container did not show up in front of the subview viewcontroller. The subviews still do not respond to touch.