Re: keeping view's bounds fixed
Re: keeping view's bounds fixed
- Subject: Re: keeping view's bounds fixed
- From: Ken Thomases <email@hidden>
- Date: Tue, 29 Jan 2008 22:51:14 -0600
On Jan 28, 2008, at 10:38 PM, Nathan Vander Wilt wrote:
I have a view whose bounds I want to keep, so that the
visible area runs from (-180,-90) to (180,90) in the
view's coordinate system. The view needs to autoresize
in all ways, so that its edges are each a fixed
distance away from the window/superview.
In my initWithFrame: method, I call [self
setBounds:NSMakeRect(-180, -90, 360, 180)]; This makes
the intial drawing work as intended, but as soon as
the window (and view) are resized, the bounds get
updated to the match the new frame size.
I tried resetting the bounds at the top of my
drawRect: method, but that doesn't work if only for
the simple reason that the "dirty" rectangle passed
wouldn't get updated. (It also had other nasty side
effects.)
In
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/WorkingWithAViewHierarchy/chapter_4_section_6.html
,
it says "If the bounds rectangle of the view has not
been explicitly set using one of the setBounds...
methods, the view's bounds rectangle is automatically
updated to match the new frame size."
Since I *have* explicitly set the bounds rectangle,
why is it still being automatically updated to match
the frame's height/width? Where can I reset the
bounds, so that they always are set to
NSMakeRect(-180, -90, 360, 180) when my view's
drawRect is called? The -viewDidEndLiveResize method
will not work, because that message isn't passed when
the window's zoom button is activated.
What is the framework using to reset the view's bounds? I would
expect it's just sending setBounds: to the view. What happens if you
override setBounds: to ignore the passed-in rectangle and always pass
NSMakeRect(-180, -90, 360, 180) to super?
-Ken
_______________________________________________
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