我通过界面生成器创建了一个名为“YLJTestViewController”的 ViewController,代码如下:
-(IBAction)DoneButtonPressed:(id)sender
{
YLJTestViewController *testViewController = [[YLJTestViewController alloc]initWithNibName:@"YLJTestViewController" bundle:nil];
[self.navigationController pushViewController:testViewController animated:YES];
//[self.view addSubview:testViewController.view];
}
但是当我使用[self.view addSubview:textViewController.view];
它时它崩溃了,但是使用[self.navigationController pushViewController:testViewController animated:YES];
它效果很好,那么有什么区别?我以为它们是一样的......