iOS开发中的页面更新、内存管理、调试与数据共享
1. 页面更新与内存优化
1.1 页面更新方法
在iOS开发中,页面更新是一个常见的需求。下面是一个用于更新页面的方法 updatePages ,以及在滚动视图滚动时调用该方法的代码:
- (void) updatePages {
int pageNumber = imagesContainer.contentOffset.x /
imagesContainer.bounds.size.width + 1;
// Load the image previous to this one
[self loadPageWithNumber:pageNumber - 1];
// Load the current page
[self loadPageWithNumber:pageNumber];
// Load the next page
[self loadPageWithNumber:pageNumber+1];
// Remove all image views that aren't on this page or the pages adjacent
// to it
for (UIImageView* imageView in imagesContainer.subviews) {
if (imageView.tag < pageNumber - 1 || imageView.tag > pageNumber
超级会员免费看
订阅专栏 解锁全文
1476

被折叠的 条评论
为什么被折叠?



