I have many subviews (button,label,textField)inside view.These are dynamically created depending on the xml elements. if xml elements are 13, the total button will also be 13 buttons. i know how to search all subviews inside view and which subviews is UIButton or UITextField by the following code.
for subView in view.subviews {
if subView is UILabel {
}
else if subView is UITextField {
}
}
what i want to know is how can i get the button's tag and title and textField's text?
Try this code:
for subView in view.subviews {
if subView is UILabel {
let label = subView as! UILabel
let labelText = label.text
}
else if subView is UITextField {
let textField = subView as! UITextField
let textFieldText = textField.text
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With