小编rkl*_*_de的帖子

UIScrollView contentSize有最大值吗?

我正在开发一个带有Ganttchart的小型iPad应用程序,该应用程序将在过去25小时内显示事件.我有5个缩放级别,分别为1小时30分钟,15分钟,5分钟和1分钟.我的细胞宽度为30像素.从每小时的Zoomlevel开始,我有25*30像素= 750宽度的内容(不需要滚动).当缩放单元格宽度保持不变时,只会有更多单元格,我可以水平滚动.它适用于30,15和5分钟.事情发生在1分钟级别(宽度为45000像素(30*1500))时,事情开始出错.滚动视图冻结(我仍然可以滚动,但显示不会更新).

drawRect:已经完成(所以它应该被正确绘制).我可以在按钮上看到一个小滚动条(甚至到达终点).所以我试图警惕宽度,似乎问题从大约16300像素宽度开始.有没有解决这个问题?还是任何一种解决方案?

我使用带有uiview(Ganttchartview)的ScrollView,其中drawRect:我已经超载了.

放大CELL_WIDTH为30且zoomLevels为25,50,75,300,1500

 -(IBAction) zoomIn:(id)sender {
    self.zoomIndex++;
    int width = CELL_WIDTH * [[self.zoomLevels objectAtIndex: self.zoomIndex] intValue];
    self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, width, self.frame.size.height);
    [self.parentView setContentSize: CGSizeMake(self.frame.size.width, self.frame.size.height)];
    [self setNeedsDisplay];
}
Run Code Online (Sandbox Code Playgroud)

drawRect绘制线条的位置

- (void)drawRect:(CGRect)rect {
Run Code Online (Sandbox Code Playgroud)
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor);
    CGContextSetLineWidth(context, 2.0);        
    int interval = [[self.zoomLevels objectAtIndex: self.zoomIndex] intValue];
    int width = CELL_WIDTH;
    for (int i = 0; i < interval; i++) {
        CGContextMoveToPoint(context, width * (i +1), START_AT); 
        CGContextAddLineToPoint(context, width * (i +1), rect.size.height); 
        CGContextStrokePath(context);
    }
    for …
Run Code Online (Sandbox Code Playgroud)

iphone uiscrollview contentsize

6
推荐指数
1
解决办法
6074
查看次数

标签 统计

contentsize ×1

iphone ×1

uiscrollview ×1