Create Object After Build?

Discussion in 'iOS Programming' started by ArtOfWarfare, Sep 22, 2009.

  1. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #1
    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.
     
  2. Darkroom Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #2
    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:

    Code:
    UITextField *myTextField = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, 25, 150)];
    
     
  3. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #3
    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.
     
  4. Troglodyte macrumors member

    Joined:
    Jul 2, 2009
    #4
    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.
     
  5. ArtOfWarfare thread starter macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007

Share This Page