1

If the code does inside of tableView:cellForRowAtIndexPath

[cell.imageView setImageWithURL:
     [NSURL URLWithString:
         [NSString stringWithFormat:
              @"http://www.mysite.com/images/pic%i.png", 
              indexPath.row % 12]]];

with no placeholder, the image won't show? (if a placeholder is used, then it will show).

I tried setting cell.imageView.frame = CGRectMake(0, 0, 300, 300); beforehand and it still won't show it. If I use the longer version setImageWithURL:placeholderImage:success:failure: and use a placeholder of nil, and use in the success block [cell setNeedsLayout];, then the image will show (but cannot be contained in the 300x300 box if cell.imageView.frame = CGRectMake(0, 0, 300, 300); is used before calling setNeedsLayout It may be 400 x 300 or 500 x 300 depending on image width). But what about the short form -- can it be made to work?

nonopolarity
  • 146,324
  • 131
  • 460
  • 740
  • What do you mean by short term? It sounds like you already have a solution using the success / failure blocks? This is the same issue really that we discussed a couple of days ago: [On iOS, how to make a cell.imageView refresh its content?](http://stackoverflow.com/questions/12209380/on-ios-how-to-make-a-cell-imageview-refresh-its-content/12209846#12209846). In UITableViewCell's implementation of `layoutSubviews` it appears it sets its `imageView`'s frame to `(0,0,0,0)` if its image is nil. So if the placeholder is nil, at layout time the resize happens. – Carl Veazey Sep 03 '12 at 04:25
  • The short form meaning the most basic usage of SDWebImage -- the very first example in the question: `setImageWithURL`. It is supposed to work, isn't it? Or it will not work at all in a UITableView? – nonopolarity Sep 03 '12 at 04:31
  • If it gives you no opportunity to pass blocks / provide delegates for callbacks, and you don't want to subclass UITableViewCell to work around the issue (e.g., restoring `self.imageView.frame` if `super` changed it to `(0,0,0,0)`, then I would expect the short form wouldn't meet your needs. – Carl Veazey Sep 03 '12 at 04:34
  • aha, I guess I don't yet fully grasp the "auto layout mechanism" yet, so that's why the question, and this looks weird too: http://stackoverflow.com/questions/12212565/how-to-make-uitableview-not-change-imageviews-frame-or-resize-the-image-to-fil – nonopolarity Sep 03 '12 at 04:40

0 Answers0