PDA

View Full Version : Create Object After Build?




ArtOfWarfare
Sep 22, 2009, 08:10 PM
Is there a way to create additional user objects that weren't added in IB programmatically after the build? Like, if I wanted to allow users to add their own text boxes and drag them around by hitting a button.

I'm sorry, the question sounds dumb, but all I've ever heard of is using IB to add user interface elements.



Darkroom
Sep 22, 2009, 08:40 PM
anything you can create in IB you can also do programatically.

to create a new UITextField programatically, you would allocate memory for it and then initiate one with a frame according to a core graphics rectangle. so something like this:


UITextField *myTextField = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, 25, 150)];

robbieduncan
Sep 23, 2009, 04:15 AM
I don't use IB at all! I create all my UI at runtime. It actually seemed easier when I wrote my app. If I ever get the time to write another I'd probably do the same thing again.

Troglodyte
Sep 23, 2009, 07:30 AM
I've written it both ways. One app uses mostly nibs and the most recent does it mostly in code. I think I prefer the latter.

ArtOfWarfare
Sep 23, 2009, 03:55 PM
Thanks for the bit of help Darkroom. :)