嗨 我是iphone新手..我已經將圖像存儲在數組中。我想知道如何在UIImageView中顯示這些圖像,其中UIImageView應根據文件列表計數動態創建增加,for循環。這是代碼在for循環中動態創建uiimageview
NSArray *filelist;
NSFileManager *filemgr;
int count;
int i=0;
int t=0;
filemgr = [NSFileManager defaultManager];
filelist = [filemgr directoryContentsAtPath: @"/Mypath/"];
NSMutableArray *imageVwArr = [[NSMutableArray alloc]init];
count = [filelist count];
count++;
for(i = 0; i < count; i++)
{
UIImageView *imgVw = [[UIImageView alloc] initWithImage:[filelist objectAtIndex:i]];
[imgVw setUserInteractionEnabled:YES];
[imgVw setTag:i];
imgVw.frame=CGRectMake(t, 0, 480, 320);
[imageVwArr addObject:imgVw];
[self.view addSubview:imgVw];
[imgVw release];
t=t+480;
}
它顯示了錯誤:「SIGABRT」: 投擲的「NSException」 程序實例接收信號後終止調用。
在那裏我做錯了,我有沒有關於提前創建動態的UIImageView 感謝想法....
這是怎麼回事? – zem 2010-10-12 12:25:36