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

Ios 在用户解除视图后重新加载tableviewcontroller,ios,objective-c,Ios,Objective C,我有一个UITableviewController和一个按钮,单击该按钮将显示另一个UIViewController [self presentViewController:newPopupViewController animated:YES completion:nil]; 然后,当我单击此UIViewController(newPopupViewController)中的关闭按钮时,将被删除,并显示以前的UITableVIewController [self dismissVie

我有一个
UITableviewController
和一个按钮,单击该按钮将显示另一个
UIViewController

    [self presentViewController:newPopupViewController animated:YES completion:nil];
然后,当我单击此
UIViewController
newPopupViewController
)中的关闭按钮时,将被删除,并显示以前的
UITableVIewController

[self dismissViewControllerAnimated:YES completion:Nil];

当出现
UITableVIewController
时,我想重新加载表格数据。我怎样才能做到这一点。

您可以使用块。假设您有FirstViewController和NewPopupViewController,那么在NewPopupViewController.h文件中

-(void)viewWillAppear:(BOOL)animated {
   // Relead data here
}
@property (nonatomic, copy) void(^ReturnBlock)(BOOL);
在NewPopupViewController.m文件中,您将关闭ViewController集

self.ReturnBlock(YES);
[self dismissViewControllerAnimated:YES completion:nil];
所以在FirstViewController中,您调用presentViewController write

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 
    }
}];

你可以用积木。假设您有FirstViewController和NewPopupViewController,那么在NewPopupViewController.h文件中

@property (nonatomic, copy) void(^ReturnBlock)(BOOL);
在NewPopupViewController.m文件中,您将关闭ViewController集

self.ReturnBlock(YES);
[self dismissViewControllerAnimated:YES completion:nil];
所以在FirstViewController中,您调用presentViewController write

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 
    }
}];

在解除VC时检索表格并重新加载它,或在
视图中重新加载表格将出现
。在演示执行某项工作的模式时,最好让演示者在执行所需操作或更新操作后立即解除。最简单的机制是提供一个块属性或委托,该属性或委托在执行操作时由呈现的控制器调用。在块/委托中,您可以在需要时执行解除<代码>视图将出现仅适用于iPhone应用程序,但是,如果你要支持带有popover的iPad,你可能会发现你需要一些更可靠的东西,因为当popover被解除时,
视图将出现
不会被调用。当你解除VC时,检索你的表格并重新加载它,或者在
视图中重新加载表格将出现
。当呈现一个模式来执行一项工作时,在执行所需操作或更新操作后,最好让演示者执行“取消”。最简单的机制是提供一个块属性或委托,该属性或委托在执行操作时由呈现的控制器调用。在块/委托中,您可以在需要时执行解除
viewwillbeen
对于仅适用于iPhone的应用程序来说是可以的,但是如果您要支持带有popover的iPad,您可能会发现您需要一些更可靠的东西,因为当popover被解除时,
viewwillbeen
不会被调用。对不起,我是新手。你能给我一个详细的例子来说明这是如何实现的吗。@Paddy在努力调用一个块之后,最好从块内部执行dismise,并且应该在
dismissViewControllerAnimated
调用的completion块内部重新加载表。如果保持如您所示的状态,我将在完成处理程序中执行块调用。还有一个问题,如何将值从
newPopupViewController
传递到
FirstViewController
?块不会执行。您可以传递值,例如,
@property(nonatomic,copy)void(^ReturnBlock)(id,BOOL)该块应可供参考,请查看此抱歉,我是新手。你能给我一个详细的例子来说明这是如何实现的吗。@Paddy在努力调用一个块之后,最好从块内部执行dismise,并且应该在
dismissViewControllerAnimated
调用的completion块内部重新加载表。如果保持如您所示的状态,我将在完成处理程序中执行块调用。还有一个问题,如何将值从
newPopupViewController
传递到
FirstViewController
?块不会执行。您可以传递值,例如,
@property(nonatomic,copy)void(^ReturnBlock)(id,BOOL)该块应可用于参考,请查看此