Basic N00b Question access UITextField defined in xib in Controller

Discussion in 'iOS Programming' started by Mac Me Up, Aug 8, 2008.

  1. Mac Me Up macrumors regular

    Jun 25, 2005
    Ok, so I'm a seasoned developer, just not a Cocoa one. I have a UITextField in a view defined in a xib. I've linked the view up with my controller and I can put buttons on there and call actions just fine. How do I access controls like text fields though so I can set and get text? I've tried all sorts of things with no luck...

    I've googled it as well but I just can't figure out something that is no doubt really simple?
  2. detz macrumors 65816

    Jun 29, 2007
    In you header file for you Delegate.

    IBOutlet UILabel *labelName;

    Then, *Control* click on the Delegate class in IB and drag a connection from the labelName to the label.


    [labelName setText:mad:"testing"];
  3. Mac Me Up thread starter macrumors regular

    Jun 25, 2005
    OK so in my interface I set up:
    IBOutlet UITextField *txtName;

    Then I control click from my delegate and set txtName to be the outlet for the text field. That all works fine. However when I make a call to:
    [txtName setText:mad:"Testing"];
    the text fields stays blank. The code is definitely being called, but on the screen nothing happens. I tried a call to setNeedsDisplay, but that didn't seem to do anything. I must be missing something really simple here?

Share This Page