如何在页面控件中获取当前显示的UItextField的实例

时间:2016-09-30 08:52:01

标签: ios uitextfield uipagecontrol

如何在UItextField中获取当前显示的PageControl的实例,因为我正在UItextField分配UItextField PageControl的实例' Add reference to Microsoft Internet Controls (SHDocVw) ' Add reference to Microsoft HTML Object Library Dim anchors As IHTMLElementCollection Dim anchor As HTMLAnchorElement Set anchors = htmlDoc.getElementsByTagName("a") For Each anchor In anchors ' anchor.Click ... this probably won't work ' I gues something like this is what you want (untested code) ie.navigate anchor.href, 1 ' BrowserNavConstants.navOpenInNewTab Next anchor 1}}

1 个答案:

答案 0 :(得分:0)

您需要使用类型转换。这段代码会这样做: 首先,您需要设置UITextField的tag属性,如

yourTextField.tag = 123

现在您可以使用像

这样的标记属性来获取yourTextField
if let theTextField = self.view.viewWithTag(123) as? UITextField {
    theLabel.text = "some text"
}