Kha*_*uke 7 uitextview ios swift
//UITextView Creation
let textarea = UITextView (frame : CGRect (x: 40, y: 100 ,width:100 , height:100))
textarea.delegate = self
textarea.tag = self.numarr
textarea.backgroundColor = UIColor(red: 0.9686, green: 0.9686, blue: 0.9686, alpha: 1.0)
textarea.layer.cornerRadius = 20.0
textarea.contentInset = UIEdgeInsetsMake(5, 5, 5, 5);
textarea.layer.masksToBounds = true
self.scrollviewxp.addSubview(textarea)
//Later after, the button function
@IBAction func loadbutton(_ sender: Any) {
if let hellatextview = self.scrollviewxp.viewWithTag(index) as? UITextView
{
hellatextview.text = "success"
}
}
Run Code Online (Sandbox Code Playgroud)
上面的代码在Xcode上没有被标记为错误,但在执行时不会更改UITextView(hellatextview)值.带有标签号(索引)的textView存在但未更改.
任何想法为什么它不起作用?我和UIButton有同样的问题
| 归档时间: |
|
| 查看次数: |
451 次 |
| 最近记录: |