UITableViewCell's imageView fit to 40x40


UITableViewCell's imageView fit to 40x40



I use the same big images in a tableView and detailView. Need to make imageView filled in 40x40 when an imags is showed in tableView, but stretched on a half of a screen. I played with several properties but have no positive result:

[cell.imageView setBounds:CGRectMake(0, 0, 50, 50)]; [cell.imageView setClipsToBounds:NO]; [cell.imageView setFrame:CGRectMake(0, 0, 50, 50)]; [cell.imageView setContentMode:UIViewContentModeScaleAspectFill]; 

I am using SDK 3.0 with build in "Cell Objects in Predefined Styles".


iPhone web apps running as native apps

1:

Javascript for “Add to Home Screen” on iPhone?
I put Ben's code as an extension in my NS-Extensions file so this I must tell any image to make a thumbnail of itself, as in:. What's the best way to communicate between view controllers?
UIImage *bigImage = [UIImage imageNamed:@"yourImage.png"]; UIImage *thumb = [bigImage makeThumbnailOfSize:CGSizeMake(50,50)]; 
Here is .h file:. How can I scan barcodes on iOS?
@interface UIImage (PhoenixMaster) - (UIImage *) makeThumbnailOfSize:(CGSize)size; @end 
and then in the NS-Extensions.m file:. __OBJC__ equivalent for Objective-C++
@implementation UIImage (PhoenixMaster) - (UIImage *) makeThumbnailOfSize:(CGSize)size {     UIGraphicsBeginImageContextWithOptions(size, NO, UIScreen.mainScreen.scale);     // draw scaled image into thumbnail context     [self drawInRect:CGRectMake(0, 0, size.width, size.height)];     UIImage *newThumbnail = UIGraphicsGetImageFromCurrentImageContext();             // pop the context     UIGraphicsEndImageContext();     if(newThumbnail == nil)          NSLog(@"could not scale image");     return newThumbnail; }  @end 
Can autocapitalize be turned off with javascript in mobile safari?“EXC_BAD_ACCESS” error when cell begins scrolling back in view?

2:

Button not removed with removedFromSuperVire
I cache a thumbnail version since using large images scaled down on the fly uses too enough memory.. Here's my thumbnail code:.
- (UIImage *)thumbnailOfSize:(CGSize)size {     if( self.previewThumbnail )     	return self.previewThumbnail; // returned cached thumbnail      UIGraphicsBeginImageContext(size);      // draw scaled image into thumbnail context     [self.preview drawInRect:CGRectMake(0, 0, size.width, size.height)];      UIImage *newThumbnail = UIGraphicsGetImageFromCurrentImageContext();	      // pop the context     UIGraphicsEndImageContext();      if(newThumbnail == nil)          NSLog(@"could not scale image");      self.previewThumbnail = newThumbnail;      return self.previewThumbnail; } 
Just make sure you properly clear the cached thumbnail if you change your original image (self.preview in my case)..

3:

I have mine wrapped in a UIView and use this code:.
imageView.contentMode = UIViewContentModeScaleAspectFit; imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth |UIViewAutoresizingFlexibleHeight; [self addSubview:imageView]; imageView.frame = self.bounds; 
(self is the wrapper UIView, with the dimensions I want - I use AsyncImageView)..

4:

I thought Ben Lachman's suggestion of generating thumbnails in advance rather than on the fly was smart, so I adapted his code so it could handle a whole array and to make it more portable (no hard-coded property names)..
- (NSArray *)arrayOfThumbnailsOfSize:(CGSize)size fromArray:(NSArray*)original {     NSMutableArray *temp = [NSMutableArray arrayWithCapacity:[original count]];     for(UIImage *image in original){         UIGraphicsBeginImageContext(size);         [image drawInRect:CGRectMake(0,0,size.width,size.height)];         UIImage *thumb = UIGraphicsGetImageFromCurrentImageContext();         UIGraphicsEndImageContext();         [temp addObject:thumb];     }     return [NSArray arrayWithArray:temp]; } 

5:

you might be able to use this?.
yourTableViewController.rowImage = [UIImage imageNamed:@"yourImage.png"]; 
and/or.
cell.image = yourTableViewController.rowImage; 
and if your images are already 40x40 then you shouldn't have to worry around setting bounds and stuff... although , i'm also new to this, so, i wouldn't know, haven't played around with Table View row/cell images much. hope this helps..

6:

I was able to make this job using interface builder and a tableviewcell. You must set the "Mode" properties for an image view to "Aspect Fit". I'm not sure how to did this programatically..

7:

Try setting UIImageView.autoresizesSubviews and/or UIImageView.contentStretch..


60 out of 100 based on 55 user ratings 380 reviews