0

面对这样的问题,当我单击表格视图单元格上的项目以将项目数据传递到详细视图控制器页面时,它会显示另一个索引项目详细信息。无法传递准确的数据。:( 有没有人可以帮助我。

这是我在 didselectrowAtIndexpath 方法中所做的示例代码

NSString *name = featured.name;
    DetailViewController *detail = [[DetailViewController alloc]initWithNibName:@"DetailViewController" 
    bundle:[NSBundle mainBundle]];
    detail.dname = name;
    [self.navigationController pushViewController:detail animated:YES];
    [detail release];
    detail = nil;
4

1 回答 1

1

您必须在 didselectrowAtIndexpath 中编写此代码,例如

 NSString *name = [Myarray objectAtIndex:indexPath.row];
detail.dname = name;
DetailViewController *detail = [[DetailViewController alloc]initWithNibName:@"DetailViewController" 
bundle:[NSBundle mainBundle]];

[self.navigationController pushViewController:detail animated:YES];
[detail release];
detail = nil;

编辑

 -(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
 {
  if([elementName isEqualToString:@"Record"]){
        //
        [passDics setObject:[forgot_pass stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] forKey:@"Forgot_Message"];

        [myarray addObject:passDics
 }
 }
于 2012-09-26T13:02:45.020 回答