ios - UIImageView resizes automatically -


i trying set image uiimageview of simpletablecell in uitableview. have changed size of imageview, whenever try set image, automatically resizes itself. tried using code here resize image , set it. works when set image dimensions (20x20) half of size of uiimageview (40x40). comes out blurred. tried setting uiaspectratiofit/uiaspectratiofill , clipstobounds = yes. nothing seems work.

another strange part imageview doesn't resize when use image directly downloaded web so:

- (void)connectiondidfinishloading:(nsurlconnection *)connection {     uiimage *userimage = [uiimage imagewithdata:userimagedata scale:self.profileimage.frame.size.height/self.profileimage.frame.size.width];      uitableviewcell *cell = [self.mytable cellforrowatindexpath:[nsindexpath indexpathforrow:0 insection:0]];      cell.imageview.image = userimage; } 

but store image documents directory , try reload in elsewhere, resizing occurs. solutions?

your simpletablecell subclass of uitableviewcell created? imageview property of subclass?

just guess:

every uitableviewcell has built-in imageview read-only property. in code posted, using default property, believe cannot have it's frame modified, it's kind of fixed in left side of cell.

look imageview property inside documentation: https://developer.apple.com/library/ios/documentation/uikit/reference/uitableviewcell_class/index.html#//apple_ref/occ/instp/uitableviewcell/imageview

so, if have custom cell own imageview, make sure not call imageview too, because may end using default uitableviewcell's property, , not own, have frame customizations , etc.

you should reference cell customclass , call property this:

- (void)connectiondidfinishloading:(nsurlconnection *)connection {     uiimage *userimage = [uiimage imagewithdata:userimagedata scale:self.profileimage.frame.size.height/self.profileimage.frame.size.width];      simpletablecell *cell = (simpletablecell*)[self.mytable cellforrowatindexpath:[nsindexpath indexpathforrow:0 insection:0]];      cell.myimageview.image = userimage; } 

don't know if problem related this, let me know if helped or not.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -