for 循环中控制器的初始化 - 泄漏问题?
我正在创建一个类似的画廊,并为每个画廊创建了一个视图控制器,其视图被添加到滚动视图中(参见下面的代码):
GalleryViewController *galViewController;
for (NSUInteger i = 0 ; i < [galleries count]; i++) {
galViewController = [[GalleryViewController alloc] init];
galViewController.record = [galleries objectAtIndex:i];
//galViewController.position = i;
galViewController.view.frame = CGRectMake(i%3*100,i/3*150,100,150);
[galViewController setDelegate:self];
[self.scrollView addSubview:galViewController.view];
//[galViewController release];
}
此代码是否泄漏?我想是的...但问题是我不知道如何处理这些控制器...我无法释放它们(因为我有一些代码可以在将来使用,例如触摸事件),而且我不'不需要将它们保存在某个地方...
这种代码有问题吗?
谢谢,
戈泰
I am creating a kinda gallery and for each gallery I created a view controller whose view is added to a scrollview (see code below) :
GalleryViewController *galViewController;
for (NSUInteger i = 0 ; i < [galleries count]; i++) {
galViewController = [[GalleryViewController alloc] init];
galViewController.record = [galleries objectAtIndex:i];
//galViewController.position = i;
galViewController.view.frame = CGRectMake(i%3*100,i/3*150,100,150);
[galViewController setDelegate:self];
[self.scrollView addSubview:galViewController.view];
//[galViewController release];
}
Is this code leaking ? I think so ... but the thing is that I don't know what to do with these controllers ... i can't release them (cause I got some code to use in the future like touches event) and I don't need to save them somewhere ...
Is this a problem to have this kind of code ?
Thks,
Gotye
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论