我有一个视图,可以在 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]; ?
在此先感谢您的帮助!