![](/img/trans.png)
[英]popup view controller dismisses immediately after open in Xcode 11.2.1
[英]Reload tableviewcontroller after user dismisses view
我有一個UITableviewController
和一個按鈕,單擊該按鈕后將出現另一個UIViewController
[self presentViewController:newPopupViewController animated:YES completion:nil];
然后,當我單擊該UIViewController
的關閉按鈕時( newPopupViewController
)將被刪除,並且將顯示之前存在的UITableVIewController
。
[self dismissViewControllerAnimated:YES completion:Nil];
當UITableVIewController
出現時,我想重新加載表數據。 我怎樣才能做到這一點。
-(void)viewWillAppear:(BOOL)animated {
// Relead data here
}
您可以使用一個塊。 假設您具有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
}
}];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.