这是我的问题:我的应用程序有一个工具栏,您可以在其中更改视图。主要的或至少启动时的一个处于横向模式,然后如果您转到任何其他视图,则处于纵向。当您尝试返回第一个(风景)时出现问题,视图以纵向显示,因此所有视图都显示错误。(它或多或少清楚吗?对不起,如果看起来很乱)。我在这里有一些代码:
V1控制器:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
V2控制器:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
-(IBAction)goToV1 {
V1Controller *v1 = [[V1Controller alloc] init];
[self.view.superview addSubview:v1.view];
}
也许在添加视图之前对对象 v1 做一些事情?我不知道,需要你的帮助。
问题已解决 在视图转换中我错过了一句话,从超级视图中删除当前视图。还有@Brad 在说什么。谢谢你。
-(IBAction)goToV1 {
V1Controller *v1 = [[V1Controller alloc] init];
[self.view.superview addSubview:v1.view];
[self.view removeFromSuperview];
}