一直苦苦挣扎这一段时间,似乎永远无法得到直接的答案.
任何帮助表示赞赏!
当我insertSubview:atIndex:在iPhone上使用该方法时,程序无法运行,并在main.m文件中使用EXC_BAD_ACCESS.但是,当我使用presentModalViewController该程序运行完美.
此外,方法switchToView在第一次使用时工作,具有不同的往返,但第二次没有.
出了什么问题?
这是我的代码:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
ShowBookDetails *sbd = [[ShowBookDetails alloc] initWithNibName:@"ShowBookDetails" bundle:nil];
[self switchToView:sbd from:self];
}
Run Code Online (Sandbox Code Playgroud)
我的方法看起来像:
-(void)switchToView:(UIViewController*)nextView from:(UIViewController*)currentView
{
[currentView.view insertSubview:nextView.view atIndex:1];
}
Run Code Online (Sandbox Code Playgroud)