开发者

UIViewController IBOutlets are nil

开发者 https://www.devze.com 2023-01-22 05:08 出处:网络
I have an UIViewController class with two labels and a UIImageView set as IBOutlets, and I have this outlets connected in my xib, I have double checked they are connected properly, however when I chec

I have an UIViewController class with two labels and a UIImageView set as IBOutlets, and I have this outlets connected in my xib, I have double checked they are connected properly, however when I check the their value in the debugger开发者_运维问答 they are 0x0 so I cant change them programatically. Any ideas on what I might be doing wrong.

Heres the header file of my code:

#import <UIKit/UIKit.h>


@interface PlateDetailViewController : UIViewController {

     IBOutlet UIImageView *image;
     IBOutlet UILabel *price;
     IBOutlet UILabel *description;

}

@property (nonatomic, retain)IBOutlet UIImageView *image;

@property (nonatomic, retain)IBOutlet UILabel *price;

@property (nonatomic, retain)IBOutlet UILabel *description;


@end


Your outlets won't get set until the view controller's view is actually instantiated, which in your case is probably happening shortly after initWithNibName:bundle:—at which point they'll still be nil. Any setup you do that involves those outlets should be happening in your view controller's -viewDidLoad method.

0

精彩评论

暂无评论...
验证码 换一张
取 消