• 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: Putting stuff into a tab view programmatically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Putting stuff into a tab view programmatically


  • Subject: Re: Putting stuff into a tab view programmatically
  • From: Brian Webster <email@hidden>
  • Date: Mon, 29 Oct 2001 11:49:24 -0600

On Sunday, October 28, 2001, at 10:30 PM, cocoa-dev-
email@hidden wrote:

What I am trying to do is have a NSTabView where the user can add a
NSTabViewItem on demand and each added NSTabViewItem will have a NSTextView
inside. The way that I think I have to this is to add a NSTextView
programmatically each time a new NSTabViewItem is added. If there is a
better/easier way then tell me. Otherwise, how would I do this?

Someone else suggested loading a nib file, which is another way to do it, but you can do it through code as well.

So far I think that I am on the right track. I make a new NSTextView with
this:

NSTextView *myTextView = [[NSTextView alloc] init];

I get the view of the NSTabView's first item (there is only one to start)
and place the NSTextView into it with this:

[[[tabView tabViewItemAtIndex:0] view] addSubview:myTextView];

Is that right? When I do that, nothing shows up. I have never tried anything
like this before, and don't really understand what a subview is. Am I going
about this in the right way?

The problem here is that you need to initialize the text view using -initWithFrame:, not just -init. Using -init causes the view to have zero size, so when you add it as a subview, it doesn't show up.

--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster


  • Prev by Date: Re: Changing the header size of a NSTableView
  • Next by Date: Re: Context menu for minimised window
  • Previous by thread: Re: Putting stuff into a tab view programmatically
  • Next by thread: NSToolbar
  • Index(es):
    • Date
    • Thread