Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSViews resizeSubviewsWithOldSize is not called on resize



I am subclassing NSView to create a custom view. Now I need to know when a resize took place to rearrange the subviews accordingly. I wanted to use resizeSubviewsWithOldSize: for that, so I overrode it in my subclass, but it does not seem to be called. What could I be missing? Or is this a bug in NSView?

setAutoResizeMode !? I am not sure... but I think you need to set it!?

What Dominik is frantically saying is that, if you read the documentation for the method you're overriding (which of course you should do if you intend to use it) says this:


"If the receiver is configured to autoresize its subviews, this method is automatically invoked by any method that changes the receiver’s frame size."

You did read that, right? So if you configure the view to auto- resize by calling -setAutoresizingMask: (not "-setAutoResizeMode", which does not exist, AFAIK), or setting the sizing springs in Interface Builder.

--
I.S.




On Jan 26, 2008, at 10:49 PM, Aulis Telle wrote:

Hello,

I am subclassing NSView to create a custom view. Now I need to know when a resize took place to rearrange the subviews accordingly. I wanted to use resizeSubviewsWithOldSize: for that, so I overrode it in my subclass, but it does not seem to be called. What could I be missing? Or is this a bug in NSView?

This is the code, I am using for testing:


@interface TestView : NSView {

}

- (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize;

@end


@implementation TestView

- (id)initWithFrame:(NSRect)frame {
  self = [super initWithFrame:frame];
  if (self) {
      // Initialization code here.
  }
  return self;
}

- (void)drawRect:(NSRect)rect {
  [[NSColor whiteColor] set];
  [NSBezierPath fillRect:rect];
}

- (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize
{
NSLog(@"SubviewsWithOldSize: %fw %fh",oldBoundsSize.width, oldBoundsSize.height);
}


@end

I am working with Leopard 10.5.1 and XCode 3.0.

Thank you for any hints?

Regards

Aulis

_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >NSViews resizeSubviewsWithOldSize is not called on resize (From: Aulis Telle <email@hidden>)
 >Re: NSViews resizeSubviewsWithOldSize is not called on resize (From: Dominik Pich <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.