The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > Developer > Omni Frameworks
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
OUIScalingScrollView fails with tiled view when zooming to < 100%, and doesn't draw until scaled Thread Tools Search this Thread Display Modes
I have spent days trying to figure this out, and have now created a very simple test project which exhibits the problem.

Symptoms:

1. when my view initially loads, it just has the checkered background showing, and does not tile the view until I zoom.

2. when scaled to less than 100%, some of my tiles are being drawn black, and some are being only partially drawn, and the rest is black.

Here is a description of my test project:

A) Single view iPad app.

B) In the storyboard, I have added a scrollview and set its minimum scale to 0.2 and maximum to 5. Its class is set to OUIScalingScrollView. Its delegate is the controller, and the controller is linked to it as its scrollView.

C) In the main storyboard, the view controller is set to be my subclass of OUIScalingViewController. I have added one property, which will point to my view. The following is the code for the view controller:

- (void)viewDidLoad
{
[super viewDidLoad];
self.myView = [[MyView alloc] initWithFrame:CGRectMake(0, 0, 8000, 8000)];
[self.scrollView addSubview:self.myView];
}

- (OUIScalingView *)viewForZoomingInScrollView:(id)sender {
return self.myView;
}

- (CGSize)canvasSize {
return self.myView.frame.size;
}

D) The implementation of my view just draws random colored tiles using the following code:

#define ARC4RANDOM_MAX 0x100000000

- (void)drawScaledContent:(CGRect)rect {
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextSaveGState(currentContext);

double r = ((double)arc4random() / ARC4RANDOM_MAX);
double g = ((double)arc4random() / ARC4RANDOM_MAX);
double b = ((double)arc4random() / ARC4RANDOM_MAX);

CGContextSetRGBFillColor(currentContext, r, g, b, 1.0f);
CGContextFillRect(currentContext, self.bounds);

CGContextRestoreGState(currentContext);
}

I have checked in OmniGraffle, and those problems are not there, so there is clearly something fundamental I am missing here.

Other things I have tried include:
- turning on and off autolayout.
- trying sizeInitialViewSizeFromCanvasSize in the controller (called from viewDidLoad)
- trying tileVisibleRect in my view (also from viewDidLoad)
- calling setNeedsDisplay on my view and the scroll view.

I also tried just filling the rect passed in to the drawScaledRect: method, but that made the drawing problem worse.

Please help! I have tried everything I can think of to sort this out, and have stripped it back to an absolutely minimal project in order to try to debug it, all to no avail.

(sorry if this is a repost - I posted it last week, but it never seemed to turn up on the forum)
 
Problem partially solved. In the view, I need to work in coordinates of the unscaled view because there is a scale transform already applied before it gets to that drawing code. So my little test where I used self.bounds was not working, and showed up when I was scaled < 1.

The other problem where the view was not drawing on load was solved by calling tileVisibleRect in viewDidLoad.

Now the only problem I have is that when the view is initially loaded, it does not allow scrolling. Working on that now...
 
Ah, the final issue was that I needed to set the content size on the scroll view. All working now! :)
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes



All times are GMT -8. The time now is 06:03 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.