Re: IB is too smart for its own good... what to do?
Re: IB is too smart for its own good... what to do?
- Subject: Re: IB is too smart for its own good... what to do?
- From: Andy Lee <email@hidden>
- Date: Wed, 31 Jul 2002 22:28:19 -0400
At 12:10 AM +0200 8/1/02, Ondra Cada wrote:
IB does not like small widgets -- eg. it won't let me to set a textview or
tableview lower than 56 pixels. Is there any simple way to overcome this?
I do agree that such a small views should be rare, but in my specific case,
I do want them... Since the view is pretty complicated (involves a number
of nested splitviews and more), I would rather not set it all
programmatically.
Two suggestions come to mind, neither ideal and neither tested by me.
Suggestion One. One way you can cheat IB (though not great, as you
will see, and frankly I would skip straight to Suggestion Two) is:
* Create a scratch window and set its min size to 0.
* Drop a table view (or whatever) into the scratch window.
* Wrap the table view in a custom view.
* Set the table view's Autosizing attributes to: springs on the
inside, struts on the outside.
* Set the custom view's Autosizing attributes the same.
* Make the table view fit snugly against the edges of the custom view.
* Make the custom view fit snugly against the edges of the window.
* Hold down Control and resize the window. This causes the window
contents to resize according to their Autosizing attributes. Since
there is no constraint on the size of the custom view, you can make
it as small as you want and the table view will shrink with it.
* Now you can select the table view and use copy and paste to put a
copy of it anywhere you want.
The drawback is, if you try to tweak the size of your table view by
dragging one of its corners it will immediately snap to IB's idea of
the proper minimum size. I think this is a nice way to drive
yourself crazy. But you *do* get to cheat IB, if only for a moment.
Suggestion Two. Use a custom view as a placeholder for your table
view, and create the table view itself at "normal" size in a separate
window. IB will let you size the custom view as small as you want.
Now here's the trick: set the class of the custom view to a simple
NSView subclass that, in its -awakeFromNib, replaces itself with the
table view. Something like the following ("compiled" in my mail app):
@interface PlaceholderView : NSView
{
IBOutlet NSView *realView; // <-- connect to your table view in IB
}
@end
@implementation PlaceholderView
- (void)awakeFromNib
{
[realView setFrame:[self frame]];
[realView removeFromSuperview]; // may not be needed
[[self superview] replaceSubview:self with:realView];
}
@end
--Andy
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.