Dynamic UI with Cocoa?

mar_ning_2000

Registered
I want to know if it's possible to dynamicly create UI elements(say I want to "add a text field whenever the user click a button") with Cocoa and Obj-C. And it would be very nice if anyone can show me a tutorial of how to do so. But if no-one has any tutorial, that's fine. As of right now, all I want to know is if dynamic UI it's possible or not.

Without Wax
Billy
 
Yes, it's possible.

I don't know any tutorial, but I'll show you a little bit pseudo-code:
In every window you hava a content-view (which is a normal NSView). You can add other Views to this view as Subview. Like this:

NSTextField *myTextField = [[NSTextField alloc] initWithBla:blabla andDing:ding];
[[theWindowToBeChanged contentView] addSubview:myTextField];

I believe, that the Superview automatically retains the View you add.
Note: Every View can have subviews. Even your textField.
 
Back
Top