我試圖創建一個圖像庫存儲在資源包中的圖像。我存儲我的圖像在NSMutable陣列我想要的是一個圖像庫....但輸出是非常不同於我期望的笏。下面的代碼工作完全fine.to更具體的葷你們幫我下面是代碼...創建一個圖像庫
_images =[NSMutableArray arrayWithObject:[UIImage imageNamed:@"logo1.png"]];
[_images addObject:[UIImage imageNamed:@"logo2.png"]];
[_images addObject:[UIImage imageNamed:@"logo3.png"]];
[_images addObject:[UIImage imageNamed:@"logo4.png"]];
[_images addObject:[UIImage imageNamed:@"logo5.png"]];
[_images addObject:[UIImage imageNamed:@"logo6.png"]];
[_images addObject:[UIImage imageNamed:@"logo7.png"]];
[_images addObject:[UIImage imageNamed:@"logo8.png"]];
[_images addObject:[UIImage imageNamed:@"logo9.png"]];
[_images addObject:[UIImage imageNamed:@"logo10.png"]];
[_images addObject:[UIImage imageNamed:@"logo11.png"]];
[_images addObject:[UIImage imageNamed:@"logo12.png"]];
[_images addObject:[UIImage imageNamed:@"logo13.png"]];
[_images addObject:[UIImage imageNamed:@"logo14.png"]];
[_images addObject:[UIImage imageNamed:@"logo15.png"]];
[_images addObject:[UIImage imageNamed:@"logo16.png"]];
NSLog(@"ha ha ha:%d",_images.count);
UIScrollView *view = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
int row=0;
int coloumn=0;
for (int i=0; i< _images.count; i++)
{
UIImage *thumb=[_images objectAtIndex:i];
UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
button.frame=CGRectMake(coloumn*100+24, row*80+30, 64, 64);
[button setImage:thumb forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
button.tag=i;
[view addSubview:button];
if (coloumn==2) {
coloumn==0;
row++;
}else {
coloumn++;
}
}
[view setContentSize:CGSizeMake(320, (row+1)*80+10)];
self.view=view;
[view release];
我試過使用three20 ...它不與標籤欄應用程序集成..並且非常複雜 – kingston 2011-06-03 07:07:46
@kingston:檢查我更新的答案。 – Jhaliya 2011-06-03 07:17:24