我以編程方式在我的視圖中添加了圖像。 (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