用户解除视图后重新加载tableviewcontroller

时间:2015-06-22 11:35:27

标签: ios objective-c

我有一个UITableviewController和一个按钮,点击另一个UIViewController后会出现

    [self presentViewController:newPopupViewController animated:YES completion:nil];

然后,当我点击此UIViewControllernewPopupViewController)中的关闭按钮时,系统会将其移除,并显示之前的UITableVIewController

[self dismissViewControllerAnimated:YES completion:Nil];

UITableVIewController出现时,我想重新加载表数据。我怎么能这样做。

2 个答案:

答案 0 :(得分:2)

-(void)viewWillAppear:(BOOL)animated {
   // Relead data here
}

答案 1 :(得分:2)

你可以使用一个块。假设你有FirstViewController和NewPopupViewController,所以在NewPopupViewController.h文件中写一下,

@property (nonatomic, copy) void(^ReturnBlock)(BOOL);

并在NewPopupViewController.m文件中解除ViewController集,

self.ReturnBlock(YES);
[self dismissViewControllerAnimated:YES completion:nil];

所以在你调用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 
    }
}];