我正在尝试切换视图。我的第一个视图是故事板,我想切换到 view2,在我的第一个视图中单击按钮时我没有问题,一切都很好。问题是当我试图返回时,屏幕变黑并且不会返回到第一个视图。这是我正在使用的代码。
视图控制器.h
- (IBAction)View2:(id)sender;
视图控制器.m
- (IBAction)View2:(id)sender {
View2 *second = [[View2 alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:second animated:YES];
}
这里是我用来从第二个视图返回到第一个视图的代码。
视图2.h
- (IBAction)back:(id)sender;
View2.m
- (IBAction)back:(id)sender {
ViewController *second = [[ViewController2 alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:second animated:YES];
}
我在做某种错误吗?
谢谢