繁体   English   中英

在2个不同的View Controller中的2个View之间切换

[英]Switching between 2 Views in 2 distinct View Controllers

我在不同ViewController的视图之间转换时遇到问题。

情况如下:

我的应用程序是使用IB完成的TabBarApplication,其中每个选项卡都包含一个UIViewController 所述UIViewController所述第一接线片(PlayerTabViewController)包含另一个UIViewController (PlayerCreationViewController)来管理将被添加为子视图的图。

我能够使用添加子视图

[self.view addSubview:playerCreationViewController.view];

在PlayerTabViewController中。

问题是从子视图中,我必须返回到父视图并重新加载它,因为它包含必须刷新的表视图。

使用[self.view removeFromSuperview]; 在PlayerCreationViewController中,我可以切换回父视图,但是无法重新加载tableview或执行其他操作。 我试图在-(void)willRemoveSubview:(UIView *)subview实现-(void)willRemoveSubview:(UIView *)subview方法,但似乎从未调用过该函数。

您是否知道我在做什么错?

您使用错误的方法继续查看下一个视图。 只需使用导航视图控制器即可从一个视图切换到另一视图。

创建一个视图对象

PlayerCreationViewController *playerViewController = [[PlayerCreationViewController alloc] initWithNibName:@"PlayerCreationViewController" bundle:nil];

[self.navigationController pushViewController:playerViewController animated:YES];

[playerViewController release];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM