Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would start by creating a UIImageView and adding it to the cell rather than using cell.imageView I would also set it within the if statement and recall it from the tag using the else statement. Otherwise it will be recreated everytime it appears in the view.</p> <p>Try</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *CellIdentifier = @"Cell"; UIImageView *myImageView; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; cell.selectionStyle = UITableViewCellSelectionStyleNone; myImageView = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 80, 80)] autorelease]; myImageView.tag = 2000+indexPath.row; [cell.contentView addSubview:myImageView]; } else { myImageView = (UIImageView*)[cell.contentView viewWithTag:2000+indexPath.row]; } photobj= [appD.array1 objectAtIndex:indexPath.row]; NSLog(@"photoobj=%@",photobj); UIImage *img1=[[[UIImage alloc]initWithData:photobj.imgdata]autorelease]; NSLog(@"frame=%f",img1.size.width); myImageView.image = img1; NSLog(@"frame=%@", imageView.image); return cell; } </code></pre> <p>I use the following code for image resize. You would just need to tweak it a bit to take your size parameters and do the scaling</p> <pre><code>- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo { image.image = img; [self _resizeImage]; [picker dismissModalViewControllerAnimated:YES]; } //function that is called by the image picker to resize the image for passing from one view to the next - (void) _resizeImage { NSInteger height; NSInteger width; height = 280; width = 280; CGImageRef imageRef = [image.image CGImage]; CGImageAlphaInfo alphaInfo = CGImageGetAlphaInfo(imageRef); CGColorSpaceRef colorSpaceInfo = CGColorSpaceCreateDeviceRGB(); if (alphaInfo == kCGImageAlphaNone) { alphaInfo = kCGImageAlphaNoneSkipLast; } CGContextRef bitmap; if (image.image.imageOrientation == UIImageOrientationUp || image.image.imageOrientation == UIImageOrientationDown) { bitmap = CGBitmapContextCreate(NULL, width, height, CGImageGetBitsPerComponent(imageRef), CGImageGetBytesPerRow(imageRef), colorSpaceInfo, alphaInfo); } else { bitmap = CGBitmapContextCreate(NULL, height, width, CGImageGetBitsPerComponent(imageRef), CGImageGetBytesPerRow(imageRef), colorSpaceInfo, alphaInfo); } if (image.image.imageOrientation == UIImageOrientationLeft) { CGContextRotateCTM(bitmap, radians(90)); CGContextTranslateCTM(bitmap, 0, -height); } else if (image.image.imageOrientation == UIImageOrientationRight) { CGContextRotateCTM(bitmap, radians(-90)); CGContextTranslateCTM(bitmap, -width, 0); } else if (image.image.imageOrientation == UIImageOrientationUp) { } else if (image.image.imageOrientation == UIImageOrientationDown) { CGContextTranslateCTM(bitmap, width, height); CGContextRotateCTM(bitmap, radians(-180.)); } CGContextDrawImage(bitmap, CGRectMake(0, 0, width, height), imageRef); CGImageRef ref = CGBitmapContextCreateImage(bitmap); UIImage *result = [UIImage imageWithCGImage:ref]; CGColorSpaceRelease(colorSpaceInfo); CGContextRelease(bitmap); CGImageRelease(ref); thisCopyImage = result; bgImage.image = thisCopyImage; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload