ViewController中顯示圖片, ViewController.h:
UIImageView *image;
@property(nonatomic,retain) IBOutlet UIImage* image ;
ViewController.m
- (id)initWithImage:(UIImage *)image
{
UIImageView * imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"nameoffile.jpg"]];
self.image = image;
[image release];
}
但並沒有讓UIImage實例鏈接成功。
IBoutlet 更應該設置關聯的是UIImageView.
@property(nonatomic,retain) IBOutlet UIImageView* imageView ;
- (id)initWithImage:(UIImage *)image
{
self.imageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"nameoffile.jpg"]] autorelease];
}