IBOutlet won't link to button

Discussion in 'iOS Programming' started by whitedragon101, Mar 11, 2013.

  1. whitedragon101 macrumors 6502a

    Joined:
    Sep 11, 2008
    #1
    I have a UIButton which I have created in interface builder and I want to access it programatically. However writing the following code and ctrl+dragging in interface builder from the view controller to the button does not display a link to the IBOutlet . It only shows the word view.

    Code:
    #import <UIKit/UIKit.h>
    
    @interface LoadScreenVC : UIViewController
    {
        IBOutlet UIButton *myButton;
    } 
    
    @property (nonatomic, retain) IBOutlet UIButton *myButton;
    
    @end
    
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Have you correctly set the view controller to that class (not just UIViewController). Do you still need to re-import headers in the latest XCode?
     
  3. whitedragon101 thread starter macrumors 6502a

    Joined:
    Sep 11, 2008
    #3
    Thanks.:)

    Didn't think about xcode itself but a clean and build plus restarting xcode seemed to work.

    All done
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    And although probably not related to your problem, you don't need to IBOutlet your button twice. In fact, you can get rid of the instance variable, since you have a property for it.
     

Share This Page