【发布时间】:2015-03-03 13:18:37
【问题描述】:
我正在尝试对 UIImage 进行子类化,这样我就可以为每个图像包含一个特殊的标题和我需要的其他信息。下面是我的 .m :
#import "Sticker.h"
@implementation Sticker
//custom init
-(instancetype)initWithTitle: (NSString *)title neededCount: (int)neededCount specialMesage: (NSString *)specialMesage andFilename: (NSString *)path {
self = [super initWithContentsOfFile:path];
if(self) {
self.title=title;
self.neededCount=neededCount;
self.specialMessage=specialMessage;
}
return self;
}
我有一个带有单个 UIImageView 的空视图控制器,我正在尝试创建一个新的贴纸对象并使用 UIImageView 中的图像。代码:
Sticker *sticker = [[Sticker alloc] initWithTitle:@"crazy clown" neededCount:50 specialMessage:@"stackoverflow" andFilename:@"clown"];
self.imageView.image=sticker;
self.imageView.hidden=NO;
由于某种原因,图像没有显示,也没有错误消息。 “小丑”是 Images.xcassets 中的 pdf 图像。谁能给我一些指示为什么这不起作用?
【问题讨论】:
标签: ios objective-c xcode uiimage