Re: create a view without IB
Re: create a view without IB
- Subject: Re: create a view without IB
- From: Andrea Salomoni <email@hidden>
- Date: Tue, 20 Dec 2005 11:32:23 +0100
Hi alexander,
Yes, I'm trying to create a new placeholder (NSView) inside a new
tabitem created on the fly... and remove it of course!
So I need to create a NSView (resizable like the one created with IB).
But the method NSView * myView = [[NSView alloc]initWithFrame:....];
I have to create a NSRect and I don't know how...
Thank you!
Andrea
Il giorno 20/dic/05, alle ore 11:23, Alexander Reichstadt ha scritto:
Are you trying to dynamically generate a new view instance --like
your chatview-- for a new tab and insert it on the fly, and remove
that tab under other conditions?
On 20.12.2005, at 11:16, Andrea Salomoni wrote:
Hi and thanks,
Il giorno 20/dic/05, alle ore 02:12, Shawn Erickson ha scritto:
On 12/19/05, Andrea Salomoni <email@hidden> wrote:
Hi and thank you,
The problem is this:
I have a nstabview created with ib and correctly connected.
When I click a certain button I would like to add a nstabviewitem
(already done) and put inside it a nstextview.
To do it I made a new nib file with IB, created a class and put
inside this view the textfiled.
Now, there isn't any problem when I instatiate this object with IB
using the placeholder outlet, but when I need to create the
placeholer (or better a new nsview object) starts the problems...
As you can see in my code:
// setting up interface
theChatView = [[privateChat alloc]init];
Create the object that contains nstextview
[[theChatView mainView] setFrame:[placeholder bounds]];
here I have to create the placeholder in other way... don't know
how
maybe
NSView * newPlaceholder = [[NSView alloc]initWithFrame:.....];
[[theChatView mainView] setFrameOrigin:NSZeroPoint];
[placeholder addSubview:[theChatView mainView]];
[_allMyViews addObject:theChatView];
[privateChat release];
This is my doubt..
Sorry I am not following what exactly you are doing (the code
snippet
above has very little context with it to help us understand what is
what) but...
1) You have a tab view that you want to add additional tabs to at
runtime.
Yes the tabview is created using IB and the tabitems at runtime
using xcode...
2) The tab view exists in a window that exists in a nib file.
Yes exist in my mainwindow
You can add tabs at runtime to an existing NSTabView using
addTabViewItem: or insertTabViewItem:atIndex. These methods require
you to supply an NSTabViewItem instance that represents the panel
you
are adding. At runtime you create NSTabViewItem using
initWithIdentifier: (the identifier object is for use to help in
identifying the tab). It appears that you understand this much.
Yes already done
The next issue issue adding a view (or hierarchy of views) into the
NSTabViewItem. You can either programmatically create the views
needed
(initWithFrame:, etc.) or could load a predefined view hierarchy
from
an already loaded nib or a secondary nib.
Yes that's it! I need to load inside the new tabitem a secondary nib.
I created a new nib that has a nsview and a nstextview inside...
now I need to add it inside my tabitem
If you use a nib then you should be calling init on any view
since the
nib contain the instances you need, you don't need to create them
just
get a hold of them. To get at them you would use an IBOutlet in the
code and connect that up with the view in your nib. In the case of a
secondary nib you likely would make the file owner of the nib the
class that contains the IBOutlet you want to use.
I don't think this is the right method... because inside my new
tabitem I cannot put via IB any nsview....
I have to create it programmatically, and then add my secondary
nib instatiating the class (in my case [theChatView mainView]...).
It is really hard to explain this in email so I will stop now... I
strongly suggest finding a good book on Cocoa development (search
the
archives and amazon for such books).
Shawn... already read a lot of books... really need only how to
set up a nsview programmatically...
-Shawn
Thank you
Andrea
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden