I'm beginner at Swift, so currently i organize most part of my app using storyboard.
I want to construct some view scrollable that contains textField and pickerView.
and each of them is stacked View, and then it is child view of view A. and view A is child view of scrollView.
help you to understand more, i'll attach my app structure.
Anyway, when i run my apps, it represent well i want to achieve, however, coudn't get any touch reaction.
keyboard isn't popup when i touch textField, pickerView scroll isn't working. I think it's because of nested view, but have no idea how to solve.
plz help! And also glad give some advice learn Swift. Thx in advance.
* edit 1) attach my code *
import UIKit
class ViewController:
UIViewController, UIPickerViewDataSource, UIPickerViewDelegate
{
@IBOutlet var outerView: UIView!
@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var statePicker: UIPickerView!
@IBOutlet weak var innerView: UIView!
@IBOutlet weak var nameInputer: UITextField!
let states = ["Alaska", "Arkansas", "Alabama", "California", "Maine", "New York"]
override func viewDidLoad() {
super.viewDidLoad()
var scrollViewHeight:CGFloat = 0.0
for view in self.view.subviews as [UIView] {
scrollViewHeight += view.frame.size.height;
}
scrollView.contentSize = CGSize(width: view.frame.width, height: scrollViewHeight)
scrollView.contentInset = UIEdgeInsetsMake(20, 0, 20, 0)
statePicker.dataSource = self
statePicker.delegate = self
statePicker.isExclusiveTouch = true
scrollView.canCancelContentTouches = false
innerView.sendSubview(toBack: outerView)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return states.count
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return states[row]
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
statePicker.isHidden = true
}
}

