Note that there are some explanatory texts on larger screens.

plurals
  1. POexc_bad_access after return cell
    primarykey
    data
    text
    <p>i am picking image from imagePickerController &amp; making it resize to 80X80 &amp; displaying in table.</p> <p>below is code for cellForRowAtIndexPath </p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } photobj= [appD.array1 objectAtIndex:indexPath.row]; NSLog(@"photoobj=%@",photobj); cell.imageView.frame=CGRectMake(0, 0, 80,80); cell.imageView.tag=2000+indexPath.row; UIImage *img1=[[[UIImage alloc]initWithData:photobj.imgdata]autorelease]; NSLog(@"frame=%f",img1.size.width); // img1=[UIImage imageWithData:photobj.imgdata]; cell.imageView.image=img1; NSLog(@"frame=%@",cell.imageView.image); return cell;//after this , crash } </code></pre> <p>after return cell it crashes if i call below image resize method </p> <pre><code>- (UIImage *)resizeImageToSize:(CGSize)targetSize withImage:(UIImage *)img { UIImage *sourceImage = img; UIImage *newImage = [[UIImage alloc]init]; CGSize imageSize = sourceImage.size; CGFloat width = imageSize.width; CGFloat height = imageSize.height; CGFloat targetWidth = targetSize.width; CGFloat targetHeight = targetSize.height; CGFloat scaleFactor = 0.0; CGFloat scaledWidth = targetWidth; CGFloat scaledHeight = targetHeight; CGPoint thumbnailPoint = CGPointMake(0.0,0.0); if (CGSizeEqualToSize(imageSize, targetSize) == NO) { CGFloat widthFactor = targetWidth / width; CGFloat heightFactor = targetHeight / height; if (widthFactor &lt; heightFactor) scaleFactor = widthFactor; else scaleFactor = heightFactor; scaledWidth = width * scaleFactor; scaledHeight = height * scaleFactor; // make image center aligned if (widthFactor &lt; heightFactor) { thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5; } else if (widthFactor &gt; heightFactor) { thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5; } } UIGraphicsBeginImageContext(targetSize); CGRect thumbnailRect = CGRectZero; thumbnailRect.origin = thumbnailPoint; thumbnailRect.size.width = scaledWidth; thumbnailRect.size.height = scaledHeight; [sourceImage drawInRect:thumbnailRect]; newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); if(newImage == nil) NSLog(@"could not scale image"); return newImage ; } </code></pre> <p>below is the code where i am calling above method UIImage *imageEdited = [info objectForKey:UIImagePickerControllerOriginalImage];</p> <pre><code>self.img_imageView2.image=[self resizeImageToSize:CGSizeMake(80, 80) withImage:imageEdited ]; photobj=[[PhotoObject alloc]init]; photobj.imgdata=UIImageJPEGRepresentation(self.img_imageView2.image, 0.9); [appD.array1 addObject:photobj]; </code></pre> <p>if i bypasses this imageresizing method then it works fine, i am not getting exactly what is the problem?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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