0

RSS を UITableview に解析していますが、データは正常に見えますが、UITableview のフィールドの 1 つを選択すると、本来あるべきデータとは異なるデータが開きます。また、テーブルビューをスクロールすると、選択した同じフィールドが再び異なるデータを返します。

では、どこで間違いを犯したのでしょうか。

RSS リンク: http://www.luaikalkatawi.me/picksound

今からありがとう。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    NSString *trimed = [[containerObject.track init] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

    NSLog(@"The link is %@", trimed);
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* cellIdentifier = @"ImgCell";

ImgCell *cell = (ImgCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];

if (cell == nil)
{
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:cellIdentifier owner:nil options:nil];
    cell = (ImgCell*)[nib objectAtIndex:0];
}

containerObject = [objectCollection objectAtIndex:indexPath.row];//use the common object again for holding the corresponding array object

///// Image reloading from HJCacheClasses
[cell.img clear];
NSString *str1 = containerObject.image; //we use image property of rss object to set the image
NSString *trimmedString = [str1 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSURL *url = [NSURL URLWithString:trimmedString];
cell.img.url = url; //set the url to img view
[self.imgMan manage:cell.img];

cell.mainText.text = containerObject.title; //title member variable for setting title
cell.detailText.text = containerObject.description;//desc variable foe
return cell;
}
4

1 に答える 1

0

なぜこれが混乱を招くのかわかりませんが、didSelectRowAtIndexPath で正しい containerObject にアクセスする必要があります。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    containerObject = [objectCollection objectAtIndex:indexPath.row];
    NSString *trimed = [[containerObject.track init] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

    NSLog(@"The link is %@", trimed);
}
于 2012-12-06T18:28:48.760 に答える