简体   繁体   English

当segue返回时,调用什么方法?

[英]When segue returns, what method is called?

I have a UITableView in a UIPopover; 我在UIPopover中有一个UITableView; when I tap on a row in the UITableView, I go to a scene (UIView) where I get start and stop times from a UIDatePicker; 当我点击UITableView中的一行时,我转到一个场景(UIView),从UIDatePicker获取开始和停止时间; then using a back button it returns to the calling UITableView, where I want to take the start and stop times and place them in a couple of rows. 然后使用后退按钮返回到调用UITableView,在这里我要获取开始时间和结束时间并将它们放置在几行中。 I save the results in the AppDelegate so I don't lose them, which probably could be done elsewhere. 我将结果保存在AppDelegate中,这样我就不会丢失它们,这很可能可以在其他地方完成。

Question is: when I dismiss the UIView with datepicker, how can I change the rows in the UITableView when it reappears? 问题是:当我用日期选择器关闭UIView时,如何重新显示UITableView中的行? I tried -viewWillAppear, but it never hits it after the UIView is dismissed. 我尝试了-viewWillAppear,但在关闭UIView后再也没有找到它。 Is there another method that I can use? 我可以使用另一种方法吗?

How about adding a notification observer to you UITableView class, eg 如何向您的UITableView类添加通知观察器,例如

[[NSNotificationCenter defaultCenter] addObserverForName:@"UpdateTable" object:self queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
    [self.myTableView reloadData];
}];

and then when you dismiss the UIView you send the notification 然后在关闭UIView时发送通知

[[NSNotificationCenter defaultCenter] postNotificationName:@"UpdateTable" object:nil];

As @Steve Waddicor hasn't added his comment as an answer, and as it is far simpler than the accepted answer, I will post it. 由于@Steve Waddicor尚未添加他的评论作为答案,并且比接受的答案要简单得多,因此我将其发布。

- (void) viewWillAppear:(BOOL)animated

This is called on the calling TableView when the back button is tapped. 点击后退按钮时,将在调用TableView上调用此方法。 Not sure why it is not being called for the original poster. 不知道为什么不要求原始海报。

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

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