Reloading a ViewController

2019-03-10 15:07发布

I have a View controller displaying some information (not table views).

I have an update call to a remote server which fills my data base. I would like to completely reload my ViewController after the update call is done.

What should I do?

9条回答
Rolldiameter
2楼-- · 2019-03-10 15:31

You Must use

-(void)viewWillAppear:(BOOL)animated

and set your entries like you want...

查看更多
聊天终结者
3楼-- · 2019-03-10 15:33

You really don't need to do:

[self.view setNeedsDisplay];

Honestly, I think it's "let's hope for the best" type of solution, in this case. There are several approaches to update your UIViews:

  1. KVO
  2. Notifications
  3. Delegation

Each one has is pros and cons. Depending of what you are updating and what kind of "connection" you have between your business layer (the server connectivity) and the UIViewController, I can recommend one that would suit your needs.

查看更多
The star\"
4楼-- · 2019-03-10 15:35

Reinitialise the view controller

YourViewController *vc = [[YourViewController alloc] initWithNibName:@"YourViewControllerIpad" bundle:nil];
[self.navigationController vc animated:NO];
查看更多
登录 后发表回答