Images from Web are not refreshed

Discussion in 'iOS Programming' started by veliborsantic74, Sep 6, 2012.

  1. macrumors newbie

    Sep 6, 2012
    I am using UITableView with approx. 10 custom subviews per cell. One of the subview is UIImageViews (2 or 3 UIImageViews per cell), and I have some problems refreshing them. I am using AFNetwork for async downloading images. [[self tableView] reloadData] works perfect for all UILabel views, but (of course) not for UIImageViews. I tried with [[self tableView] setNeedsDisplay], [[self tableView] setNeedsLayout], but with no luck. I am really stumped on this part of refreshing, and I have no idea what to do else. If you need pieces of code, please let me know what you need to help me.

    If I really need one of these messages, please let me know where exactly to put them - before or after adding subviews?
  2. macrumors 65816


    Dec 29, 2010
    Aartselaar // Antwerp // Belgium
    Err, you already have the images in there, if you need to update them, you need to retrigger the download? or save them to the disk, and then check if they are there, or are you talking about reusing cell views?
  3. macrumors newbie


    Jul 10, 2012
  4. thread starter macrumors newbie

    Sep 6, 2012
    jnoxx, this is method where I put full URL in array logoKluba
    -(void) ucitajLogoKluba
        NSURL *logoKlubaURL = [NSURL URLWithString:adresa];
        NSData *logoKlubaHTMLPodaci = [NSData dataWithContentsOfURL:logoKlubaURL];
        TFHpple *logoKlubaParser = [TFHpple hppleWithHTMLData:logoKlubaHTMLPodaci];
        NSString *logoKlubaXpathUpit = @"//div[@class='oddsTableLink']/img";
        NSArray *logoKlubaNiz = [logoKlubaParser searchWithXPathQuery:logoKlubaXpathUpit];
        NSMutableArray *logoKluba = [[NSMutableArray alloc] initWithCapacity:0];
        for (TFHppleElement *element in logoKlubaNiz)
            Par *trenutniLogoKluba = [[Par alloc] init];
            [logoKluba addObject:trenutniLogoKluba];
            trenutniLogoKluba.nazivLogoKluba = [element objectForKey:@"src"];
        _logoKluba = logoKluba;
        [[self tableView] reloadData];
    In - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    I have:
    logoKlub1 = [[UIImageView alloc] initWithFrame:CGRectMake(50, 40, 75, 16)];
            logoKlub1.layer.cornerRadius = 5.0f;
            logoKlub1.clipsToBounds = YES;
            [cell.contentView addSubview:logoKlub1];
       //     [logoKlub1 setNeedsLayout];                    //DODAO OVO DA MI OSVJEŽAVA I SLIKE NAKON REFRESHA
            logoKlubX = [[UIImageView alloc] initWithFrame:CGRectMake(130, 40, 75, 16)];
            logoKlubX.layer.cornerRadius = 5.0f;
            logoKlubX.clipsToBounds = YES;
            [cell.contentView addSubview:logoKlubX];
         //   [logoKlubX setNeedsLayout];                    // DODAO OVO DA MI OSVJEŽAVA I SLIKE NAKON REFRESHA
            logoKlub2 = [[UIImageView alloc] initWithFrame:CGRectMake(210, 40, 75, 16)];
            logoKlub2.layer.cornerRadius = 5.0f;
            logoKlub2.clipsToBounds = YES;
            [cell.contentView addSubview:logoKlub2];
            [logoKlub1 setImageWithURL:[NSURL URLWithString:punaAdresa1]] ;
            [logoKlubX setImageWithURL:[NSURL URLWithString:@""]];
            [logoKlub2 setImageWithURL:[NSURL URLWithString:punaAdresa2]];
    where setImageWithURL is a method from AFNetwork

    The whole thing is an application where I download current odds from different bookies.

Share This Page