Re: addSubview: and positioning at the bottom of a NSWindow
Re: addSubview: and positioning at the bottom of a NSWindow
- Subject: Re: addSubview: and positioning at the bottom of a NSWindow
- From: Stefano Pigozzi <email@hidden>
- Date: Tue, 4 Aug 2009 09:51:53 +0200
I solved this. With setAutoresizingMask: I can prevent the scrollview
containing the tableview to grow with the window frame. Posting my
solution for the sake of people that might have similar issues in the
future.
NSRect bounds = [infoView bounds];
NSRect frame = [[searchWindow contentView] frame];
NSRect w_frame = [searchWindow frame];
w_frame.size.height += bounds.size.height;
w_frame.origin.y -= bounds.size.height;
// Locking the scrollview to the top
NSUInteger mask = [scrollView autoresizingMask]; // this was set in IB
[scrollView setAutoresizingMask:NSViewMinYMargin];
[NSAnimationContext beginGrouping];
[searchWindow setFrame:w_frame display:YES animate:YES];
[infoView setFrame:NSMakeRect(0.0, 0.0, frame.size.width,
bounds.size.height)];
[[searchWindow contentView] addSubview:infoView];
[NSAnimationContext endGrouping];
// Making the scrollview autoresize again in all directions.
[scrollView setAutoresizingMask:mask];
On Aug 3, 2009, at 9:19 PM, Chase Meadors wrote:
Consider using NSDrawer. It can contain a content view (i.e. your
info view) and can be attached to any side of a parent window, and
be shown or hidden.
If you don't want to use this, however, just grab the content view's
frame,
NSRect r = [[window contentView] frame]
and then call:
[[window contentView] setFrame:NSMakeRect(r.origin.x, r.origin.y,
r.size.width, r.size.height + *however much you need*)];
Then set the frame of your subview and add it.
On Aug 3, 2009, at 1:51 PM, Stefano Pigozzi wrote:
Hello,
I'm trying to do something simple, I have a NSWindow containing a
NSTableView that resizes with the with the window. When I click on
one element I want to display additional information in a subView
that I'm adding with [[theWindow contentView] addSubview:infoView];
The problem is when I do this the infoView is overlapped with the
scrollView. How can I make it appear below the other views in the
window? (maybe making the window grow in size). Some code examples
or pointers would be great. (http://i31.tinypic.com/2wf1f95.jpg
this is what it should look like after adding the subview)
Thank you for your time.
stefano
_______________________________________________
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:
@gmail.com
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:
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:
This email sent to email@hidden