我在尝试子类UIImageView
以在其中添加一些自定义功能。我开始尝试做基础知识,只是用给定图像初始化对象并将其显示在屏幕上。
使用UIImageView
一切工作正常,但如果我将我的对象从UIImageView
更改为我的自定义类,则不会显示图像。
这是我到目前为止已经完成:目标c子类UIImageView
//Imager.h
#import <UIKit/UIKit.h>
@interface Imager : UIImageView {
}
-(id) init;
-(void) retrieveImageFromUrl: (NSString *)the_URL;
@end
//Imager.m
#import "Imager.h"
@implementation Imager
@synthesize image;
-(id)init
{
self = [super init];
return self;
}
-(void) retrieveImageFromUrl: (NSString *)the_URL{
//Not implemented yet
}
@end
于是,我用这statment:cell.postImage.image = [UIImage imageNamed:@"img.png"];
在此之前被执行,我也有postImage = [[UIImageView alloc] init];
如果postImage被声明为的UIImageView一切正常如预期。但是,如果我将其更改为Imager,则不会显示任何内容。 我错过了什么?
为什么你有'@synthesize图像;'?你没有定义一个属性?它看起来像你的例子中缺少的东西。 – Kobski 2011-04-04 13:29:06