One of my applications has property of images as background of Cells in UITableView, while testing, every thing was fine, the images and the cell hight was exactly as tested in code, but when it was uploaded, i tried to download it several times via iphone , ipad, the cell was stretched and the measures applied while testing completely was different,images not clear at all, the applications contain images with 2 sizes(the other is retina size @2x) i dunno whats the matter or what am missing, am using XCode 4.2, Please advice,
Appreciate your swift replies, well, its in-app-purchase contains many albums, these albums are located each of them in uitable view cell with an image, when downloaded, the image will change and uitableview automatically refreshed,first of all the images are set in array in (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];'
and thats where the tableView is loaded
-(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;
}
where change1,2,3.....are the replaced images when the albums are downloaded.
Use only the name, not the extension.
UIImage *change1 = [UIImage imageNamed:@"playalbum-06"];