1
我一直在学习iOS开发并遇到问题。 我有具有UIPickerView
如下:a类(它是隐藏的开始)如何访问自定义类中的UIPickerView
public class MyController: UIViewController,
UIPickerViewDelegate,
UITableViewDataSource,
UITableViewDelegate {
@IBOutlet var myPickerView: UIPickerView!
}
我有另一个类,我需要访问此选择器视图,并使其可见,当用户开始编辑的文本字段(它有一个标记= 2)
public class MyClass2: UITableViewCell,
UITextFieldDelegate {
@IBOutlet vat myTextField: UITextField! {didSet {myTextField.delegate = self } }
public func textFieldShouldBeginEditing(textField: UITextField) -> Bool {
if (textField.tag == 2) {
// Somehow access the picker view from the other class and change its property, hidden, to false
}
}
}
谢谢。
你应该阅读协议和delegati上;然后在创建单元格时将视图控制器设置为委托,并根据需要让单元调用委托方法 – Paulw11