我只习惯于 xcode 中的 Storyboard,但我的新老板希望每个人都在 xib 文件中完成,我没有经验。
到目前为止,我所做的只是创建了一个新的单 View 应用程序,并在“viewDidLoad”方法下添加了代码..
UILabel *scoreLabel = [ [UILabel alloc ] initWithFrame:CGRectMake(0, 0.0, 150.0, 43.0) ];
[self addSubview:scoreLabel];
和线
[self addSubview:scoreLabel];
抛出错误 'No Visible @Interface for 'ViewController' 声明选择器 'addSubView'
我到底在这里想念什么?
最佳答案
self
是 UIViewController
.您将 subview 添加到 UIView
.所有你需要的是:
[self.view addSubview:scoreLabel];
关于iphone - 以编程方式将 uilabel 添加到 xib 的 View Controller 会导致 'No Visible @Interface' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14463084/