UIScrollView 中具有多个笔尖的未声明视图
我试图使用 3 个笔尖在同一个 UIScrollView 中渲染 3 个不同的视图。但是 xcode 不断返回视图未声明的错误。
- (void)loadView {
[super loadView];
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scroll.pagingEnabled = YES;
NSInteger numberOfViews = 3;
MainWindow.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[scroll addSubview:MainWindow.view];
view2.view.frame = CGRectMake(self.view.frame.size.width, 0, self.view.frame.size.width, self.view.frame.size.height);
[scroll addSubview:view2.view];
view3.view.frame = CGRectMake(self.view.frame.size.width*2, 0, self.view.frame.size.width, self.view.frame.size.height);
[scroll addSubview:view3.view];
scroll.contentSize = CGSizeMake(self.view.frame.size.width * numberOfViews, self.view.frame.size.height);
[self.view addSubview:scroll];
[scroll release];
}
在此示例中,Xcode 会说 MainWindow、view2 和 view 3 未声明。我做错了什么?
I'm trying to render 3 different views in the same UIScrollView using 3 nibs. But xcode keeps giving back the error that the views are undeclared
- (void)loadView {
[super loadView];
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scroll.pagingEnabled = YES;
NSInteger numberOfViews = 3;
MainWindow.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[scroll addSubview:MainWindow.view];
view2.view.frame = CGRectMake(self.view.frame.size.width, 0, self.view.frame.size.width, self.view.frame.size.height);
[scroll addSubview:view2.view];
view3.view.frame = CGRectMake(self.view.frame.size.width*2, 0, self.view.frame.size.width, self.view.frame.size.height);
[scroll addSubview:view3.view];
scroll.contentSize = CGSizeMake(self.view.frame.size.width * numberOfViews, self.view.frame.size.height);
[self.view addSubview:scroll];
[scroll release];
}
In this example Xcode would say MainWindow, view2 and view 3 are undeclared. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来声明一个对象
通过“您可能希望做什么
来声明和定义
view2
”Declare an object by
Do you may wish to do
to declare and define
view2