2

I am trying to parse text with images in the UITableView and I can only see the text for every line but I can't see the images.

Here is my code;

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

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [self.anaTablo dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}


    UILabel *textBaslik = (UILabel *) [cell viewWithTag:3];
    UIImage *imagePic = (UIImage *) [cell viewWithTag:7];

    textBaslik.text =[titleArray objectAtIndex:indexPath.row];
    imagePic.images = [imageArray objectAtIndex:indexPath.row];

return cell;

}

but it didn't works and after searching I have tried this to;

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

    UILabel *textBaslik = (UILabel *) [cell viewWithTag:3];
    UIImage *imagePic = (UIImage *) [cell viewWithTag:7];

    textBaslik.text =[titleArray objectAtIndex:indexPath.row]; 

    NSString *str1 = [[NSString alloc] initWithFormat:@"%@", imageArray];

    NSData *bgImageData = [NSData dataWithContentsOfFile:str1];

    UIImage *img1 = [UIImage imageWithData:bgImageData];

    imagePic = [img1 objectAtIndex:indexPath.row];

return cell

}

Am I doing something wrong? I am kind new to Xcode

Thanks from now.

Luai Kalkatawi
  • 1,492
  • 5
  • 25
  • 51

2 Answers2

3

Check this tutorial about parsing RSS with XMLParses, it works perfectly. Wiki XML parse data

You should check this sample code using TBXML framework TBXML parser

Aitul
  • 2,982
  • 2
  • 24
  • 52
  • My RSS is working fine and I can see all the texts in the UItableView but I couldn't parse the picture that is my problem. Thanks for the link but it doesn't solve my issue – Luai Kalkatawi Oct 11 '12 at 14:57
  • are you getting a url of the image? check this link that will answer your question http://stackoverflow.com/questions/7565123/load-image-to-a-tableview-from-url-iphone-sdk – Aitul Oct 11 '12 at 14:58
  • you have to download the images from the url in a asyncronous way(it´s better).try the apple sample Lazy tableviews, it´s a good point to start http://developer.apple.com/library/ios/#samplecode/LazyTableImages/Listings/Classes_RootViewController_m.html – Aitul Oct 11 '12 at 15:01
  • Thank you Aitul for you help but this is difficult for mw is there easier way? I could share my code with you mine is very simple code. – Luai Kalkatawi Oct 11 '12 at 15:23
  • Here you have an easy example to undertand it:http://blog.mugunthkumar.com/coding/ios-tutorial-image-cache-and-loading-thumbnails-using-mknetworkkit/ please vote my up if the answer are interesting – Aitul Oct 11 '12 at 15:28
  • Thank you Aitul for your help but it is not my answer and I left a vote for you. – Luai Kalkatawi Oct 11 '12 at 15:40
3

I check you code and i change the following

NSString *str1 = [[NSString alloc] initWithFormat:@"%@", imageArray];
NSData *bgImageData = [NSData dataWithContentsOfFile:str1];
UIImage *img1 = [UIImage imageWithData:bgImageData];

imagePic = [imageArray objectAtIndex:indexPath.row];

cell.imageView.image=imagePic;

in the delegate method

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

Now a new error appear, check it

Aitul
  • 2,982
  • 2
  • 24
  • 52
  • My problem was this too NSString *trimmedString = [imageLink.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; – Luai Kalkatawi Oct 17 '12 at 19:42