Re: Creating controls dynamically
Re: Creating controls dynamically
- Subject: Re: Creating controls dynamically
- From: j o a r <email@hidden>
- Date: Wed, 30 Mar 2005 08:43:23 +0200
No, that's not right. Anything you can do with nib files, you can do
with code. The reverse is not always true, because you are limited to
what properties of a particular object type that are exposed in the
inspector for that object in IB.
That said, it's often much easier to create your interface using nib
files. I can guarantee that you underestimate how many properties that
needs to be configured for a view / control when you have to do it in
code...
You can of course also use a combination, where you load most of your
interface from nib files, and just tweak some things in code where
needed.
Back to the original problem in this thread: Have you investigated
using a table view, or a NSMatrix with NSImageCells wrapped in a scoll
view, to display your images? Don't spend time with creating a custom
control if one of the standard controls can do the job for you!
I also think that you can find more info on this topic if you check the
list archives. Search for "iPhoto", as I think that people have tried
to re-create it's multi-image-view before. Not sure though.
j o a r
On 2005-03-30, at 08.09, Anish Kumar wrote:
Hi,
Using nib files to create controls dynamically may be a better option
as you can add new objects for instance a button or something else to
the nib file and have that for your application. I think for creating
buttons dynamically you must use nib files only. Also you said you
want to display undetermined number of images and this may point that
you are probably displaying a set of images to the user to select any
one of them ...like thumbnails....So if you want the action to be
performed when a user select the image(a button), probably using
buttons may be useful in this context.
But if your needs are limited to what you have done so far...you may
well go with it...
Happy coding.....
regards,
-Anish
http://www.qubyx.com/
Rohit Bhatia wrote:
Hi,
You are right, I want to display undetermined number of images. I
was
able to create NSImageViews at run time after some tweaking to my
code.
Now, when my initWithFrame function is called, I store the reference
to
my main View. Later on (upon an action) I add a new NSImageView as a
subview to the main one. I haven't used the NIB file for it, I just
created it as just another object, is there any difference if I use
the
NIB file for it?
This is how I am storing a reference to my Main View right now.
- (id)initWithFrame:(NSRect) frameRect
{
myMainImageView = self;
}
It works fine, is there a better method to do it (may be the NIB
file).
Later on, on an action, I add subviews to this main view.
Thanks for the help.
Rohit
-----Original Message-----
From: Anish Kumar [mailto:email@hidden] Sent: Tuesday, March 29,
2005 10:20 AM
To: Rohit Bhatia; email@hidden
Subject: RE: Creating controls dynamically (Rohit Bhatia)
Hi,
Your code seems to show that you want to display undetermined number
of
images during runtime. I feel the best way to do this is to use a
seperate nib file with a instantiated object which is a sub-class of
NSView(or NSImageView).
You can then load the nib file as and when you want and set an image
of
your choice to the sub-class of NSView on the nib file. After loading
and setting the image you can add that sub-class of NSView as a
sub-view
of your main view.
Try this and if you face any problem implementing this mail me back.
regards,
-Anish
http://www.qubyx.com/
_______________________________________________
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
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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