Why Is My Image Not Showing Up (From Web Service)

Discussion in 'iOS Programming' started by loon3y, Sep 18, 2012.

  1. macrumors 65816


    Oct 21, 2011
    (Tabbar App)

    im calling a web service in my first viewcontroller and I'm trying to set it to an array and make it appear on my salesviewcontroller's table

    if ([elementName isEqualToString:@"itemno"])
            displayText.text = capturedCharacters;
            if([capturedCharacters isEqualToString:@""])
              theDataObject.prodCode = capturedCharacters;
                NSString *sURL = [[NSString alloc] initWithString:[NSString stringWithFormat:@"%@%@.jpg", theDataObject.imageURL, salesIMG.salesCode]];
                NSData *mydata = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",sURL ]]];
                salesIMG.styleImage = [[UIImage alloc] initWithData:mydata];

    salesIMG.styleImage is the global variable where im storing my data, and heres the coding for my tableview in the salesVIewController

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
        GlobalStrings* theDataObject = [self theGlobalClass];
        static NSString *CellIdentifier = @"SalesCell";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        Sale *mySale = [Sale alloc];
        mySale = [theDataObject.prodTableArray objectAtIndex:[indexPath row]];
        UILabel *codeLabel = (UILabel *) [cell viewWithTag:100];
        codeLabel.text = mySale.salesCode;
        UILabel *descriptLabel = (UILabel *) [cell viewWithTag:101];
        descriptLabel.text = mySale.salesDescript;
        UILabel *priceLabel = (UILabel *) [cell viewWithTag:103];
        priceLabel.text = mySale.salesPrice;
        UIImageView *salesImageView = (UIImageView *) [cell viewWithTag:102];
        UILabel *quantityLabel = (UILabel *) [cell viewWithTag:104];
        quantityLabel.text = mySale.salesQuantity;
        salesImageView.contentMode = UIViewContentModeScaleAspectFit;
        salesImageView.image = mySale.styleImage;
        return cell;

    it worked for the other app, im not sure why it doesnt work. i need to do this because there is a 5-8 second delay when i press the the salesviewcontroller tab, because before i was calling the webservice everytime to show the image

Share This Page