【问题标题】:UIScrollView setContentSizeUIScrollView setContentSize
【发布时间】:2010-08-09 08:15:54
【问题描述】:

我有一个麻烦,我需要使用 pdf(页面)的内容制作滚动视图,该内容的前 8 页大小,当我已经看到 8 页时,我需要为新页面扩展内容大小并这样做,该滚动视图向我显示新页面,但他再次显示从开始滚动视图开始的页面。

我需要实现什么?

【问题讨论】:

  • 是否有特殊原因将滚动视图大小设置为仅适合 8 页?从一开始就使所有页面都适合并在页面可见时加载它们似乎要容易得多。
  • 有理由,我必须实现从缓冲区加载页面,而缓冲区中的页面只能定位 8 个页面,当缓冲区中的页面结束时,我们将更多页面添加到缓冲区中。 pdf的所有页面我都没有问题)

标签: iphone pdf uiscrollview scrollview


【解决方案1】:

也许您正在寻找的是 setContentOffset。

【讨论】:

  • 如果我实现 setContentOffset,我的滚动条从第一页开始滚动,而不是从当前页开始。
  • 您需要将内容偏移量设置为当前页面。
  • 告诉我你是如何实现 setContentOffset 的,我看看能不能告诉你出了什么问题。
【解决方案2】:
if(currentPoint.x == screenWidth){

    currentPage += 1;
    screenWidth += 768.0f;

    [self loadScrollViewWithPage:currentPage];

    if(realLastPage - currentPage <= step){

        for(int i = 0; i < step; i++){

            [myPage loadViewForPage:page cycles:realLastPage + i append:YES filename:filename array:pageArray];
            NSLog(@"size of pageArray after adding elements: %d", [pageArray count]);
            NSLog(@"page # added: %d", realLastPage + i); 

            //[pageArray removeObjectsInRange:NSMakeRange(0, step)];
            //NSLog(@"size of pageArray after deleting elements: %d", [pageArray count]);

        }
        realFirstPage += step;
        contentInstep += step;
        scroller.contentInset = UIEdgeInsetsMake(0, 0, 0, kScrollObjWidth * contentInstep);
        NSLog(@"real first page: %d; contentInstep: %d", realFirstPage, contentInstep);

    }
}

NSLog(@"currentPage: %d", currentPage);

这是代码,现在我尝试实现 scroller.contentInset 来扩展我的滚动内容大小。

【讨论】:

    【解决方案3】:

    我将重申 Erik B 所说的:首先让滚动视图尽可能大,然后按需加载页面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多