我有一個樣本代碼在從下面的代碼在GridView來顯示圖像...但它爲所有的圖像顯示相同的圖像...該方法是以下..陣列圖像的顯示
- (MMGridViewCell *)gridView:(MMGridView *)gridView cellAtIndex:(NSUInteger)index
{
MMGridViewDefaultCell *cell = [[MMGridViewDefaultCell alloc] initWithFrame:CGRectNull];
cell.textLabel.text = [NSString stringWithFormat:@"Cell %d", index];
cell.imageView.image = [UIImage imageNamed:@"cell-image.png"];
// this needs to be change load from the array
}
- (NSInteger)numberOfCellsInGridView:(MMGridView *)gridView
{
return 64;
}
現在我有圖像的陣列,需要投入的是cellAtIndex
方法,但我應該怎麼做才能轉化爲對於所有圖像放入數組..
數組就像
-(void)viewDidLoad{
_imageDatas = [DelegateClass mag]._imageData;
_finaImages = [[NSMutableArray alloc]init];
}
_finaImages = [[NSMutableArray alloc]init];
for (int i = 0; i < [_imageDatas count]; i++) {
[_finaImages addObject:[self loadImage:i]];
}
- (UIImage *)loadImage:(int)index {
@try {
UIImage* image = [[UIImage alloc] initWithData:[_imageDatas objectAtIndex:index]] ;
return image;
}
@catch (NSException *exception) {
NSLog(@"ImageFullScreenViewController - loadImage Exception Name = %@ Exception Reason = %@",[exception name],[exception reason]);
}
如何從下面的陣列從數據到上述imageView.image
讓我指出在第四行有一個額外的}你的viewDidLoad,它應該使它無法編譯。 – WolfLink 2013-03-22 05:40:30