我在iOS项目中有几个hunderd .jpgs
在/Resources
中。从NSArray中将图像加载到UITableViewCell中
这里是viewDidLoad方法:
- (void)viewDidLoad {
NSArray *allPosters = [[NSBundle mainBundle] pathsForResourcesOfType:@"jpg" inDirectory:@"."];
[super viewDidLoad];
}
上面成功地加载所有.jpgs
的成NSArray
。 我只需要这个数组内UITableViewCells
在UITableView
这里显示的所有.jpgs
的是-(UITableViewCell *)tableView:cellForRowAtIndexPath:
方法:
-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
NSDictionary *posterDict = [allPosters objectAtIndex:indexPath.row];
NSString *pathToPoster= [posterDict objectForKey:@"image"];
UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell ==nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]autorelease];
}
UIImage *theImage = [UIImage imageNamed:pathToPoster];
cell.ImageView.image = [allPosters objectAtIndex:indexPath.row];
return cell;
}
我知道这个问题是与cell.ImageView.image
,但我不知道是什么问题是什么?我如何从阵列中抓取每个.jpg
并在每一行中显示?
谢谢,虽然我收到'请求会员'ImageView'的东西不是结构或联盟'? – mozzer 2011-03-07 14:38:06
噢,没有发现。当然是cell.imageView.image。没有资本我 – 2011-03-07 14:39:36