我有一个示例代码可以从下面的代码中在 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