I am developing a small iPad application with Ganttchart that will show Events in the last 25 hours. I have 5 zoom levels each for 1 hour, 30 minutes, 15 minutes, 5 minutes and 1 min. My cells are 30 pixels wide. Starting with the hourly Zoomlevel, I have a width of 25 * 30 pixels = 750 for the content (no need to scroll yet). When the cell width scaling remains unchanged, there will only be more cells, and I can scroll horizontally. It is great for 30, 15 and 5 minutes. When it comes to the 1-minute level (width 45,000 pixels (30 * 1500), everything starts to go wrong. The scrollview freezes (I can still scroll, but the display does not refresh).
Space drawRect: (so it should be drawn correctly). I see a small scroll bar on the button (it even comes to the end). So I tried to guard the width, and it seems that the problems start with a width of about 16300 pixels. Is there any work for this? Or any solution?
I am using ScrollView with uiview (Ganttchartview) enabled, which drawRect: I am overloaded.
zoom in where CELL_WIDTH is 30 and ZoomLevels are 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]; }
drawRect where the lines are drawn
- (void)drawRect:(CGRect)rect {
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 (int i = 0; i < NUMBER_OF_ROWS; i++) { CGContextMoveToPoint(context, 0, START_AT + i * CELL_WIDTH); CGContextAddLineToPoint(context, rect.size.width, START_AT + i * CELL_WIDTH); CGContextStrokePath(context); } }