Reputation: 1
This is my first time doing Xcode swift project, so please bear with me. I am trying to add a scroll view onto my input page. But after putting the text field on the scroll view, I cannot input anything on the text field any more. Please help me.
import UIKit
class AddInfoViewController: UIViewController, UIScrollViewDelegate {
@IBOutlet var scrollView: UIScrollView!
var containerView2: UIView!
@IBOutlet var test2: UITextField!
@IBOutlet var test1: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
let containerSize = CGSize(width: 300.0, height: 1000.0)
containerView2 = UIView(frame: CGRect(origin: CGPoint(x: 0, y: 0), size:containerSize))
scrollView.addSubview(containerView2)
//set up the minimum & maximum zoom scales
let scrollViewFrame = scrollView.frame
let scaleWidth = scrollViewFrame.size.width / scrollView.contentSize.width
let scaleHeight = scrollViewFrame.size.height / scrollView.contentSize.height
let minScale = min(scaleWidth, scaleHeight)
scrollView.minimumZoomScale = minScale
scrollView.maximumZoomScale = 1.0
scrollView.zoomScale = 1.0
}
Upvotes: 0
Views: 1530
Reputation: 71852
I think your ScrollView is covering all the things on your ViewController Like this way :
And you have to arrange it like this :
May be this can help you.
Upvotes: 1
Reputation: 2380
Are You Adding textField in storyboard or programmatically?
i think if you are adding scrollView Programmatically Then You also have to add textfield Programmatically! Or ScrollView Override UITextField Objects in storyBoard!
in xib Click on "Show Document Outline"(on left Bottom Corner)! Check
View
ScrollView
Round Style Text Field
Round Style Text Field
This shows that Your textField Are on ScrollView!
if You have it like this
View
Round Style Text Field
Round Style Text Field
ScrollView
Then Your TextField Are Override By Scroll View!
Upvotes: 0