2013-04-09 102 views
0

我的故事板项目中有两个viewcontrollers。一旦我点击ViewcontrollerOne中的tableview行,它就会通过将value和settext传递给viewcontrollerTwo中的标签来显示该行的内容。但是,当我尝试第三个视图控制器,并通过单击按钮是第三个viewcontroller发送具有不同值的相同的数组名称,但它不显示在viewcontrollerTwo中的标签。刷新ViewController?

为什么?我如何刷新ViewDidload上的viewcontroller或移动到viewcontrollerTwo?

目前,我将这段代码添加到viewcontrollerTwo的viewDidLoad:方法中。

[self.view setNeedsDisplay] 
+0

您需要发布您的代码。 – rdelmar 2013-04-09 04:13:55

+0

好,如果你想你也可以调用[yourcustomcontroller.tableView reloadData]; – 2013-04-09 04:50:07

回答

0

你可以把这个在刷新你的视图控制器的applicationDidBecomeActive

[yourcontroller reloadInputViews]; 

可是,为什么你正在使用相同的tableview你不重装你的tableview。

0

你总是可以使用NSNotificationCenter更新父视图 - 控制

在父视图控制器把这个:

//since child view controller calls turnItOff, notification center calls function "turnButtonCountinuesOff" 
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(turnButtonCountinuesOff) name:@"turnItOff" object:nil]; 

turnButtonCountinuesOff是你在父视图 - 控制

功能在你的孩子的ViewController把这个:

//connect to parent UI view controller calls notification turnItOff. 
[[NSNotificationCenter defaultCenter] postNotificationName:@"turnItOff" object:nil]; 

希望它有帮助。