2

我将 UIControl 子类化来创建我的自定义控件,但我使用 Interface Builder 设计了它。现在我想“导出”它并将它用于另一个应用程序,我不知道我应该做什么才能重用它。它使用 initWithCoder 加载。

我在互联网上搜索了很多,但我没有找到我的问题的正确答案。

谢谢你。

4

1 回答 1

0

也许您需要在 ViewController 方法的 viewDidLoad 中使用以下代码:

CustomControl *control = [[[NSBundle mainBundle] loadNibNamed:@"CustomControl" owner:nil options:nil] objectAtIndex:0];
control.frame = CGRectMake(5.0f, 0.0f, 310.0f, 180.0f);
[self.view addSubview:control];
于 2012-02-26T03:47:26.107 回答