Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableview-didSelectRowAtIndexPath显示不同的数据问题_Ios_Uitableview_Didselectrowatindexpath - Fatal编程技术网

Ios UITableview-didSelectRowAtIndexPath显示不同的数据问题

Ios UITableview-didSelectRowAtIndexPath显示不同的数据问题,ios,uitableview,didselectrowatindexpath,Ios,Uitableview,Didselectrowatindexpath,我正在将RSS解析为UITableview,数据看起来应该是这样的,但当我在UITableview中选择一个字段时,它会打开不同的数据,然后是它应该打开的数据。此外,当我滚动tableview时,我选择的同一字段再次给出不同的数据 请问我哪里会犯错误 RSS链接: 从现在开始谢谢你 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSString

我正在将RSS解析为UITableview,数据看起来应该是这样的,但当我在UITableview中选择一个字段时,它会打开不同的数据,然后是它应该打开的数据。此外,当我滚动tableview时,我选择的同一字段再次给出不同的数据

请问我哪里会犯错误

RSS链接:

从现在开始谢谢你

- (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;
}

我不知道为什么这会让您感到困惑,但正确的containerObject应该在didSelectRowAtIndexPath中访问

- (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);
}

如何更新ContainerObject.track选择?问题可能在于如何将数据加载到表格视图单元格(如问题中所述滚动表格视图)。我建议您在中为-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath添加代码Question@Lefteris谢谢你的回复。我已经添加了代码,如果它是不够的,我会在这里添加一个共享表中的所有代码。它的工作。这是你第二次帮我谢谢你。