I have a custom text field that is inside a view that is inside a scrollview, the touch event apparently does not work when I put the parent view of it inside the Uiscroll view, which can be
follows the code:
func loadScrollView()
{
if metadataBuilder.cells.count > 0
{
for i in 0...metadataBuilder.cells.count - 1
{
if i < metadataBuilder.cells.count
{
//stopLoading(result: [], title: "")
fieldValues = metadataBuilder.fieldValues
auxView.addSubview(metadataBuilder.cells[i])
metadataBuilder.cells[i].topAnchor.constraint(equalTo: auxcontraintTop, constant: 8).isActive = true
metadataBuilder.cells[i].leftAnchor.constraint(equalTo: auxView.leftAnchor, constant: 16).isActive = true
metadataBuilder.cells[i].rightAnchor.constraint(equalTo: auxView.rightAnchor, constant: -16).isActive = true
metadataBuilder.cells[i].heightAnchor.constraint(equalToConstant: 100).isActive = true
scrollView.setContentOffset(CGPoint(x: 0, y: 0), animated: false)
auxcontraintTop = metadataBuilder.cells[i].bottomAnchor
}
}
}
self.view.addSubview(scrollView)
scrollView.alwaysBounceVertical = true
scrollView.showsVerticalScrollIndicator = true
scrollView.alwaysBounceHorizontal = false
scrollView.showsHorizontalScrollIndicator = false
// constrain the scroll view to 8-pts on each side
scrollView.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 0).isActive = true
scrollView.topAnchor.constraint(equalTo: view.topAnchor, constant: 0).isActive = true
scrollView.rightAnchor.constraint(equalTo: view.rightAnchor, constant: 0).isActive = true
scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0).isActive = true
scrollView.addSubview(auxView)
auxView.topAnchor.constraint(equalTo: scrollView.topAnchor, constant: 0).isActive = true
auxView.leftAnchor.constraint(equalTo: scrollView.leftAnchor, constant: 0).isActive = true
auxView.rightAnchor.constraint(equalTo: scrollView.rightAnchor, constant: 0).isActive = true
auxView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor, constant: 0).isActive = true
scrollView.autoresizingMask = UIViewAutoresizing.flexibleHeight
}
override func viewDidLayoutSubviews() {
scrollView.isScrollEnabled = true
scrollView.contentSize = CGSize(width: view.bounds.width, height: heightView)
}