【发布时间】:2011-11-10 21:13:48
【问题描述】:
我以编程方式在视图中添加了图像。但是当我切换到使用代码查看添加图像的位置时,我的应用程序已中止
UIImageView *countryFlag = [[UIImageView alloc] initWithImage:[UIImage imageNamed:CountryFlagImage]];
[countryFlag setFrame:CGRectMake(0, 0, 50, 50)];
[self.view addSubview:countryFlag];
[countryFlag release];
countryFlag = nil;
在 - (id)initWithNibName 我有
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil CountryFlagImage:(NSString*)imageFlagName
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
CountryFlagImage = [NSString stringWithString:imageFlagName];
}
return self;
}
CountryFlagImage 我取自之前的主视图。
【问题讨论】:
-
CountryFalgImage 是一个属性吗?我发现有点怀疑 stringWithString: 行。更好的是我不明白你想要做什么......
-
CountryFlagImage 是在你的头文件中声明的实例变量吗?
-
你的堆栈跟踪说什么?
标签: objective-c view sdk