FROM : Steve Weller
DATE : Mon Mar 03 05:00:30 2008
On Mar 2, 2008, at 4:03 PM, Steve Weller wrote:
>
> I have a custom view with a custom subview. I can't seem t make the
> bounds of the subview stick. When the view changes the subview's
> frame, I want the subview's bounds to stay exactly as I set them the
> first time. The whole point of having this subview is to have a
> separate coordinate system.
>
> I create the subview like this:
>
> // Add page into our view
> pageView = [[BTPPPageView alloc] initWithFrame:[self pageFrame]];
> [pageView
> setBounds:NSMakeRect(0,0,pageBoundsSize.width,pageBoundsSize.height)];
> [self addSubview:pageView];
>
> and I reposition the subview's frame when the view's frame changes:
>
> [pageView setFrame:[self pageFrame]];
>
> The subview bounds are set correctly at the start, but if I make the
> subview's frame larger, the bounds are scaled larger too. I thought
> from this in the NSView docs that the subview's bounds would stay
> fixed:
>
> If your view does not use a custom bounds rectangle, this method
> also sets your view bounds to match the size of the new frame. You
> specify a custom bounds rectangle by calling setBounds:,
> setBoundsOrigin:, setBoundsRotation:, or setBoundsSize:explicitly.
> Once set, NSView creates an internal transform to convert from frame
> coordinates to bounds coordinates.
>
> I am using setBounds, so why is it not preventing the scaling? My
> view has the Autoresizes subviews flag off. The view is created in
> IB, the subview in code, as above.
Having discovered that all uses of setFrame that I could find that
handle scaling reset the bounds every time, I changed the code to:
[pageView setFrame:[self pageFrame]];
[pageView
setBounds:NSMakeRect(0,0,pageBoundsSize.width,pageBoundsSize.height)];
and this achieves what I wanted to do.
DATE : Mon Mar 03 05:00:30 2008
On Mar 2, 2008, at 4:03 PM, Steve Weller wrote:
>
> I have a custom view with a custom subview. I can't seem t make the
> bounds of the subview stick. When the view changes the subview's
> frame, I want the subview's bounds to stay exactly as I set them the
> first time. The whole point of having this subview is to have a
> separate coordinate system.
>
> I create the subview like this:
>
> // Add page into our view
> pageView = [[BTPPPageView alloc] initWithFrame:[self pageFrame]];
> [pageView
> setBounds:NSMakeRect(0,0,pageBoundsSize.width,pageBoundsSize.height)];
> [self addSubview:pageView];
>
> and I reposition the subview's frame when the view's frame changes:
>
> [pageView setFrame:[self pageFrame]];
>
> The subview bounds are set correctly at the start, but if I make the
> subview's frame larger, the bounds are scaled larger too. I thought
> from this in the NSView docs that the subview's bounds would stay
> fixed:
>
> If your view does not use a custom bounds rectangle, this method
> also sets your view bounds to match the size of the new frame. You
> specify a custom bounds rectangle by calling setBounds:,
> setBoundsOrigin:, setBoundsRotation:, or setBoundsSize:explicitly.
> Once set, NSView creates an internal transform to convert from frame
> coordinates to bounds coordinates.
>
> I am using setBounds, so why is it not preventing the scaling? My
> view has the Autoresizes subviews flag off. The view is created in
> IB, the subview in code, as above.
Having discovered that all uses of setFrame that I could find that
handle scaling reset the bounds every time, I changed the code to:
[pageView setFrame:[self pageFrame]];
[pageView
setBounds:NSMakeRect(0,0,pageBoundsSize.width,pageBoundsSize.height)];
and this achieves what I wanted to do.
| Related mails | Author | Date |
|---|---|---|
| Steve Weller | Mar 3, 01:03 | |
| Steve Weller | Mar 3, 05:00 | |
| Jens Alfke | Mar 3, 08:00 |






Cocoa mail archive

