我以编程方式在我的视图中添加了图像。 (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我从以前的主视图了 - 但是,当我切换到查看其中的代码
UIImageView *countryFlag = [[UIImageView alloc] initWithImage:[UIImage imageNamed:CountryFlagImage]];
[countryFlag setFrame:CGRectMake(0, 0, 50, 50)];
[self.view addSubview:countryFlag];
[countryFlag release];
countryFlag = nil;
在添加图片我的应用程序已经中止。
是CountryFalgImage属性?我发现有点怀疑stringWithString:行。更好,我不明白你想做什么... –
是CountryFlagImage一个实例变量声明在你的头文件? – Jim
你的堆栈跟踪说什么? – fredrik