【发布时间】:2012-02-16 16:45:50
【问题描述】:
我的一个应用程序具有图像属性作为 UITableView 中单元格的背景,在测试时,一切都很好,图像和单元格高度与代码中测试的完全一样,但是当它上传时,我尝试下载它通过 iphone 、 ipad 几次,细胞被拉伸,测试时应用的措施完全不同,图像根本不清晰,应用程序包含 2 种尺寸的图像(另一个是视网膜尺寸 @2x)我不知道这是怎么回事或什么我失踪了,我正在使用 XCode 4.2, 请指教,
感谢您的快速回复, 好吧,它的应用内购买包含许多相册,这些相册每个都位于带有图像的uitable view单元格中,下载时,图像会更改并且uitableview会自动刷新,首先将所有图像设置在数组中( viewDidLoad)
'
UIImage *awwal = [UIImage imageNamed:@"album-01.png"];
UIImage *teni = [UIImage imageNamed:@"album-02.png"];
UIImage *telet = [UIImage imageNamed:@"album-03.png"];
UIImage *rabee = [UIImage imageNamed:@"album-04.png"];
UIImage *akhir = [UIImage imageNamed:@"album-05.png"];
UIImage *ba3do = [UIImage imageNamed:@"album-zaman.png"];
UIImage *aatiha = [UIImage imageNamed:@"album-tarab.png"];
UIImage *j3ala = [UIImage imageNamed:@"album-monawaa.png"];
NSMutableArray *images = [[NSMutableArray alloc] initWithObjects: awwal, teni, telet, rabee, akhir, ba3do, aatiha, j3ala, nil];
self.AlbumsImages = images;
[images release];'
这就是加载 tableView 的地方
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CellIdentifier";
// NSLog(@"%@",AlbumsImages);
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
NSUInteger row = [indexPath row];
NSArray *myPathList = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *myPath = [myPathList objectAtIndex:0];
NSString* storagePath = [myPath stringByAppendingPathComponent:@"purchasedAlbums.plist"];
NSArray* valueList = [[NSArray alloc] initWithContentsOfFile:storagePath];
UIImage *change1 = [UIImage imageNamed:@"playalbum-06.png"];
UIImage *change2 = [UIImage imageNamed:@"playalbum-07.png"];
UIImage *change3 = [UIImage imageNamed:@"playalbum-08.png"];
UIImage *change4 = [UIImage imageNamed:@"playalbum-09.png"];
UIImage *change5 = [UIImage imageNamed:@"playalbum-11.png"];
UIImage *change6 = [UIImage imageNamed:@"playalbum-12.png"];
UIImage *change7 = [UIImage imageNamed:@"playalbum-10.png"];
UIImage *change8 = [UIImage imageNamed:@"playalbum-13.png"];
int i;
for (i = 0; i <= [AlbumsImages count]; i++) {
if ([[valueList objectAtIndex:i+1] intValue]) {
if (i == 0) {
[AlbumsImages replaceObjectAtIndex:0 withObject:change1];
}
if (i == 1) {
[AlbumsImages replaceObjectAtIndex:1 withObject:change2];
}
if (i == 2) {
[AlbumsImages replaceObjectAtIndex:2 withObject:change3];
}
if (i == 3) {
[AlbumsImages replaceObjectAtIndex:3 withObject:change4];
}
if (i == 4) {
[AlbumsImages replaceObjectAtIndex:4 withObject:change5];
}
if (i == 5) {
[AlbumsImages replaceObjectAtIndex:5 withObject:change6];
}
if (i == 6) {
[AlbumsImages replaceObjectAtIndex:6 withObject:change7];
}
if (i == 7) {
[AlbumsImages replaceObjectAtIndex:7 withObject:change8];
}
}
}
//cell.textLabel.text = [AlbumsView objectAtIndex:row];
cell.imageView.image = [AlbumsImages objectAtIndex:row];
cell.tag=row+1;
return cell;
}
其中change1,2,3.....是下载相册时替换的图片。
【问题讨论】:
-
提供您的代码.. 设置图像的位置。
-
上传后多次尝试下载是什么意思?还请提供一些代码,以便我们查看导致问题的原因。
-
亲爱的非常感谢,问题已用代码修改,如果可能,请检查并提出建议,
标签: objective-c ios xcode uitableview ios4