viewDidLoad后加载数据
我有一个 viewController,它要求我加载一系列图像并将它们显示在屏幕上,但是在 viewDidLoad 中加载这些图像需要一段时间,并且在视图出现在屏幕上之前存在延迟。
有没有一种方法可以让我在 viewDidLoad 中只加载屏幕上可见的前 5 个图像,然后在 viewController 加载后立即加载剩余的图像?
这是 viewWillAppear 或 viewDidAppear 的用途吗? 是否有其他地方最适合用于加载内容而不延迟用户的响应时间?
非常感谢!
I have a viewController that requires I load a whole series of images and display them on the screen, but loading those images in viewDidLoad takes a while and there is a delay before the view appears on screen.
Is there a way that I could load just the first 5 images that are visible on the screen in viewDidLoad, and then load the remaining images immediately after the viewController has loaded?
Is this what viewWillAppear or viewDidAppear are for?
Is there somewhere else that is best used for loading content without delaying the response time for the users?
Thanks so much in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
评论(3)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
您可以使用
viewWillAppear
来显示前 5 个图像/数据,而不会对用户造成任何延迟,并在viewDidAppear
中显示剩余数据。you could use
viewWillAppear
to get first 5 images/data to display without any delay to user and rest data you could inviewDidAppear
.