[英]Reload tableviewcontroller after user dismisses view
I have a UITableviewController
and a button where upon click another UIViewController
will appear 我有一个
UITableviewController
和一个按钮,单击该按钮后将出现另一个UIViewController
[self presentViewController:newPopupViewController animated:YES completion:nil];
Then, when i click the close button in this UIViewController
( newPopupViewController
) will be removed and the UITableVIewController
that was there before will be displayed. 然后,当我单击该
UIViewController
的关闭按钮时( newPopupViewController
)将被删除,并且将显示之前存在的UITableVIewController
。
[self dismissViewControllerAnimated:YES completion:Nil];
When the UITableVIewController
appears i want to reload the table Data. 当
UITableVIewController
出现时,我想重新加载表数据。 How can i do this. 我怎样才能做到这一点。
-(void)viewWillAppear:(BOOL)animated {
// Relead data here
}
You can use a block. 您可以使用一个块。 Suppose you have FirstViewController and NewPopupViewController, so in the NewPopupViewController.h file write,
假设您具有FirstViewController和NewPopupViewController,因此在NewPopupViewController.h文件中编写以下内容:
@property (nonatomic, copy) void(^ReturnBlock)(BOOL);
and in the NewPopupViewController.m file where you dismiss the ViewController set, 然后在NewPopupViewController.m文件中关闭ViewController集,
self.ReturnBlock(YES);
[self dismissViewControllerAnimated:YES completion:nil];
So in the FirstViewController where you call the presentViewController write, 因此,在调用presentViewController的FirstViewController中,
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
NewPopupViewController *newPopupViewController = [storyboard instantiateViewControllerWithIdentifier:@"FirstView"]; // The Identifier should be from the Storyboard
[self presentViewController:newPopupViewController animated:YES completion:nil];
[newPopupViewController setReturnBlock:^(BOOL flag)
{
if (!flag)
{
//reload you table here
}
}];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.