我遇到了尝试让新的viewcontroller工作的问题。我有UITableView
从plist
文件加载。第一行将转到detailviewcontroller
,但下一行不会出错并且有错误。第二个控制器中的错误DetailViewController2
可能无法响应“从文件中获取步骤”。有什么想法吗?
DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
[detailViewController getStepsFromFile:[files objectAtIndex:indexPath.row]];
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
DetailViewController2 *detailViewController2 = [[DetailViewController2 alloc] initWithNibName:@"DetailViewController2" bundle:nil];
[detailViewController2 getStepsFromFile:[files objectAtIndex:indexPath.row]];
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController2 animated:YES];
[detailViewController2 release];
答案 0 :(得分:1)
我使用此代码从tableview导航不同的两个屏幕。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0)
{
DetailViewController *C = [[DetailViewController alloc]init];
[self.navigationController pushViewController:C animated:NO];
[c release];
}
else
{
DetailViewController1 *C = [[DetailViewController1 alloc]init];
[self.navigationController pushViewController:C animated:NO];
[C release];
}
答案 1 :(得分:0)
在.h中声明方法-getStepsFromFile
,以使其对类的任何实例可见。
编辑: 尝试没有动画的第一个,然后动画第二个,如下:
[self.navigationController pushViewController: detailViewController animated: NO];
[self.navigationController pushViewController: detailViewController2 animated: YES];