views:

38

answers:

1

i am trying to load a image in uiwebview in a tableView cell using

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}

NSInteger Index=indexPath.row;
switch (Index) 
{

case 0:

[cell.contentView addSubview:webView];

        NSString *str=[[NSString alloc]initWithFormat:@"%@",[appDelegate.respSrcUrl objectAtIndex:0]];

        NSURL *url = [NSURL URLWithString: str];

        NSString *htmlString = @"<html><body><img src='%@' width='900'></body></html>";
        NSString *imageHTML  = [[NSString alloc] initWithFormat:htmlString,url];


        webView.scalesPageToFit = YES;

        [webView loadHTMLString:imageHTML baseURL:nil];


break;

default:

break;
}

but no image is getting loaded in the webview. how can i display the image in webview??

A: 

Make sure you return cell; at the end of the delegate method.

Alex Reynolds
the webview is displaying but the image in not loading??
hemant
Looks like he failed to paste the entire method
willcodejavaforfood