• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: IB is too smart for its own good... what to do?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Accessing "current document" when not the frontmost application
  • Next by Date: Re: IB is too smart for its own good... what to do?
  • Previous by thread: Accessing "current document" when not the frontmost application
  • Next by thread: Re: IB is too smart for its own good... what to do?
  • Index(es):
    • Date
    • Thread