IBOutlet is nil inside custom UIView (Using STORYBOARD)

前端 未结 7 1580
忘掉有多难
忘掉有多难 2020-12-25 13:22

I have a custom UIView class. Inside it I have declared an IBOutlet property for UIImageView.

#import 

        
7条回答
  •  清酒与你
    2020-12-25 13:47

    in your .h file you need to replace your code:

    #import 
    
    @interface SettingItem : UIView{
    
    }
    
    @property (strong, nonatomic) IBOutlet UIImageView *myImage;
    
    @end
    

    With this code

    #import 
    
    @interface SettingItem : UIView{
    
      IBOutlet UIImageView*myImage;
    
    }
    
    @end
    

    You are not actually telling Xcode what myImage is, you are just making it a strong, nonatomic property

提交回复
热议问题