刚开始 iPhone 开发,我似乎错过了一些基本的东西。
在基于视图的应用程序中,我在 ViewController 实现文件中添加了一个 UIView 子类,并且可以设置一个值:
- (void)viewDidLoad {
[super viewDidLoad];
CGRect myRect = CGRectMake(20, 50, 250, 320);
GraphView *graphView = [[GraphView alloc] initWithFrame:myRect];
[self.view addSubview:graphView];
graphView.myString = @"Working here";
}
当我尝试使用同一文件中的操作更改相同的值时,构建失败,因为未声明 graphView:
- (void)puschButton1 {
graphView.myString = @"Not working here";
}
因为我使用 UIView 子类,所以我的 GraphView 实例没有出口。
如何获得对我的子视图的引用?还是应该以其他方式完成?
提前致谢
坦率