Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread Display Modes
Old Sep 12, 2012, 11:22 AM   #1
macrumors newbie
Join Date: Sep 2012
Refreshing images in UITableView

This problem drives me crazy for 9 days. I am downloading some logos from web and set them in TableView. That works OK with iOS 5 built-in method, but the problem is refreshing images. For refreshing I am using PullRefreshTableViewController by Leah Culver (https://github.com/leah/PullToRefresh).
I tried also with AFNetworking and SDWebImage but the problem still exists.
This is part of code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
NSString *CellIdentifier = [NSString stringWithFormat:@"Cell%i", indexPath.row];
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    NSString *osnovnaAdresaString = @"http://www.odds1x2.com/";
    if (cell == nil)
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
logoKlub1 = [[UIImageView alloc] initWithFrame:CGRectMake(50, 40, 75, 16)];
[cell.contentView addSubview:logoKlub1];

logoKlubX = [[UIImageView alloc] initWithFrame:CGRectMake(130, 40, 75, 16)];
[cell.contentView addSubview:logoKlubX];

logoKlub2 = [[UIImageView alloc] initWithFrame:CGRectMake(210, 40, 75, 16)];
[cell.contentView addSubview:logoKlub2];

[self downloadLogoFromAddress:Address1 forClub:logoKlub1]; // Address1 is NSString web address
[self downloadLogoFromAddress:AddressX forClub:logoKlubX]; // AddressX is NSString web address
[self downloadLogoFromAddress:Address2 forClub:logoKlub2]; // Address2 is NSString web address
return cell;
And method where the logo should sit on its place:
-(void) downloadLogoFromAddress: (NSString *) webAddress forClub: (UIImageView *) clubLogo
    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:webAddress]];
    [NSURLConnection sendAsynchronousRequest:request
                                       queue:[[NSOperationQueue alloc] init]
                            ^(NSURLResponse *response, NSData *data, NSError *error) {
                               [[NSOperationQueue mainQueue] addOperationWithBlock:
                                    UIImage* pic = [[UIImage alloc]initWithData:data];
                                    [nizLogoKaoSlike addObject:piv]; // tried set logo from NSMutableArray
                                    NSLog(@"Glavni thread? %d", [NSThread isMainThread]); // yes, it is

                                    clubLogo.image = pic;
							    clubLogo.image = [nizLogoKaoSlike lastObject];
                                    [clubLogo setNeedsLayout];

                               }];   }]; }
Instead [clubLogo setNeedsLayout] also tried [clubLogo setNeedsDisplay], but with no luck. After pulling down nizLogoKaoSlike contains refreshed images which number is incremented as I scroll down. I am clueless how to force UIImageViews logoKlub1, logoKlubX and logoKlub2 to refresh. ☹
veliborsantic74 is offline   0 Reply With Quote
Old Sep 12, 2012, 08:49 PM   #2
macrumors 68030
MattInOz's Avatar
Join Date: Jan 2006
Location: Sydney
You might want to have a look at Apple sample code project. Pretty sure there is WWDC video that goes with it.

There is no such thing as "Collective Wisdom"
[ iPhone 5s, iPad Mini, 13" MacBookPro 2.7Ghz, 27"Al iMac i7, Black MacBook 13"]
MattInOz is offline   0 Reply With Quote
Old Sep 13, 2012, 05:31 AM   #3
Thread Starter
macrumors newbie
Join Date: Sep 2012
EDIT: Interesting, I have noticed that all three images on UIImageViews in the last cell are changed, not only once, but more times - like on the slot machines.

Last edited by veliborsantic74; Sep 13, 2012 at 06:39 AM.
veliborsantic74 is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Images for Whatsapp - Emoticons, images, posters... to share in social networks leomark iPhone and iPod touch Apps 0 Apr 11, 2014 03:48 AM
app refreshing itself upon opening! volcom883 iOS 7 8 Oct 29, 2013 12:16 PM
refreshing dektop? stanw Mac OS X 10.7 Lion 3 Oct 2, 2013 07:40 AM
i phone 4 how to down load images and videos partialy.and delete images from albums Radhakrishnan iPhone Tips, Help and Troubleshooting 0 Jul 9, 2013 03:45 AM
Who is already refreshing ?? penajmz iPhone 35 Sep 14, 2012 02:25 AM

Forum Jump

All times are GMT -5. The time now is 11:17 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2015, MacRumors.com, LLC