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

 
How to work with OUIScalingScrollView Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
I'm trying to use the scaling scroll view, but am not sure how to set it up to do the right thing. I am setting everything up programmatically in a subclass of OUIScalingViewController. The following is the code I have written:

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.scrollView = [OUIScalingScrollView new];
self.scrollView.delegate = self;
self.scrollView.backgroundColor = [UIColor greenColor];
self.scrollView.translatesAutoresizingMaskIntoCons traints = NO;
self.scrollView.minimumZoomScale = 0.25f;
self.scrollView.maximumZoomScale = 5.0f;
[self.view addSubview:self.scrollView];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[sv]|" options:0 metrics:nil views:@{@"sv":self.scrollView}]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[sv]|" options:0 metrics:nil views:@{@"sv":self.scrollView}]];

self.mapView = [OUIScalingView new];
self.mapView.backgroundColor = [UIColor redColor];
self.mapView.translatesAutoresizingMaskIntoConstra ints = NO;
[self.scrollView addSubview:self.mapView];
self.mapView.frame = CGRectMake(0.0f, 0.0f, 2000.0f, 4000.0f);
self.scrollView.contentSize = self.mapView.frame.size;

UILabel *label = [UILabel new];
label.translatesAutoresizingMaskIntoConstraints = YES;
label.text = @"This is a label.";
label.backgroundColor = [UIColor yellowColor];
[self.mapView addSubview:label];
label.frame = CGRectMake(50, 50, 100, 100);

label = [UILabel new];
label.translatesAutoresizingMaskIntoConstraints = YES;
label.text = @"This is a label.";
label.backgroundColor = [UIColor blueColor];
[self.mapView addSubview:label];
label.frame = CGRectMake(750, 750, 100, 100);
}

What happens is that when I pinch to zoom out, the whole thing gets zoomed out and says it's going to zoom to fit, and appears to do so at 26% size, but the labels don't scale with the view - well they do while you're pinching, but when you let go, they end up their original size. So the first question is how do I get the view and all its subviews to scale?

When I zoom in, the zoom factor goes up but when I let go, it snaps back to 72%. Why is that, and how do I fix it?

What I want to end up with is something a bit like OmniGraffle where the users can pinch to zoom the canvas, and it does what you expect. My program will resize the canvas as required, adding subviews to represent the different objects I want to draw. I will be able to calculate the canvas size and exact frames of all the graphic objects I want to display.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes



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


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