【发布时间】:2015-03-08 02:15:47
【问题描述】:
我不知道为什么会这样。
在我的应用程序中,我有
- ViewController.swift
- CustomUIView.swift
- CustomUIView.xib
在我的 ViewController.swift 中
var customView: CustomUIView = NSBundle.mainBundle().loadNibNamed("CustomUIView", owner: self, options: nil).first as CustomUIView;
customView.setupControl();
self.view.addSubview(customView);
在我的 CustomUIView.swift 中,我尝试更改在 CustomUIView.XIB 中创建的 UIButton 的属性,例如
@IBOutlet weak var button: UILabel!
func setupControl()
{
label.frame = CGRect(x: 0 , y: 30, width: 320, height: 240); //THIS DOES NOT WORK
label.text = "BLABLABLA"; //THIS WORKS
}
我只能从 InterfaceBuilder 修改 UIButton 的属性。
对为什么会发生这种情况有任何想法吗?
【问题讨论】: