0

我有一个视图,可以在 viewDidLoad 期间将 100 多个图像加载到屏幕上,如下所示:

cover = [[UIImageView alloc] initWithImage:[UIImage imageNamed:currentQuestion.image]];
cover.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:currentQuestion.image ofType:@"jpg"]];
cover.contentMode = UIViewContentModeScaleAspectFit;
cover.transform = CGAffineTransformMakeScale(0.1, 0.1);
cover.frame = CGRectMake(30, (current*70), 100, 100);
[scrollView2 addSubview:cover];

这需要一些时间来加载(5 秒以上),我记得知道你应该只在屏幕上加载你需要的东西,所以我更喜欢加载前 10 个图像,允许视图加载,然后添加其他功能中的剩余图像,因为它们最初在屏幕外,直到用户向下滚动。最好的地方在哪里?我是否只是在 viewDidLoad 中调用另一个函数,例如 [self loadTheRest]; 或 [self performSelector:@selector(loadTheRest) withObject:nil afterDelay:0.3f]; ?

在此先感谢您的帮助!

4

2 回答 2

0

你可以实现 UIScrollViewDelegate 的scrollViewDidScroll:方法,这样当用户滚动到新位置时,您会加载可见的图像。

有关详细信息,请参阅UIScrollViewDelegate 协议参考

于 2011-03-23T16:09:16.407 回答
0

。H

UIScrollView* scrollView;
@property (nonatomic,retain)  IBOutlet UIScrollView* scrollView;

.m

- (void)viewDidLoad {
    scrollView.contentSize = self.view.frame.size;
}
于 2011-03-23T16:17:02.623 回答