Adding a child view to a zoomed parent view
Adding a child view to a zoomed parent view
- Subject: Adding a child view to a zoomed parent view
- From: Tae Won Ha <email@hidden>
- Date: Thu, 28 Feb 2013 22:18:58 +0100
Hi, guys.
I have the following situation and need help:
* I have a parent view 'pv' which has a unit scale {x, x} where x != 1, say x = 1.1. I used the -scaleUnitSquareToSize: method for this.
* I instantiate a child view 'cv' using -initWithFrame: with a rect, say {100, 100, 100, 100}.
* I add cv to pv using -addSubview:
As far as I understand, the frame I used to instantiate cv is interpreted in the parent view's coordinate system. Thus, after -addSubview:, cv should have the frame {100, 100, 100, 100} in pv's coordinate system, right? In my situation, before cv's -drawRect: is called, -setFrame: of cv is called with {90.91, 90.91, 90.91, 90.91}, ie the child view is displaced and is drawn smaller than intended.
It's about the following file, from line 700:
https://github.com/qvacua/qmind/blob/issue/QM-7/Qmind/QMMindmapView.m
To reproduce the problem, just run the app with DEBUG=1 and click the zoom in button in the toolbar (or pinch) and click anywhere. In the log, you will see that -setFrame: of the child view gets invoked with weird rect. In the above file, I use {1000, 500, 100, 100} for the initial frame of the child view and get {909.09, 454.55, 90.91, 90.91} after adding it to the parent view with unit scale {1.1, 1.1}.
When I use a dummy project where both the parent and child view are dummies, it works as intended, ie no -setFrame: call to the child view. Thus, the child view is not displaced and has the right size.
Am I missing something or doing something wrong?
Thanks in advance and best,
Tae
--
http://qvacua.com
https://github.com/qvacua/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden