Calling method in current view controller from App Delegate in iOS

后端 未结 4 2146
耶瑟儿~
耶瑟儿~ 2020-12-01 01:23

I have two view controllers (BuildingsViewController and RoomsViewController) that both use a function within the App Delegate called upload. The upload function basically d

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-01 02:16

    To do the refresh of the view do not call viewWillAppear if the view is already displayed. What you want to do is the following:

    When ConnectionDidFinishLoading method is triggered post a notification

    [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshView" object:nil];
    

    In your viewController observe for this notification. You do it by adding this code to your init or viewDidLoad method

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshView:) name:@"refreshView" object:nil];
    

    Now implement -(void)refreshView:(NSNotification *) notification method in your viewController to manage your view to your liking.

提交回复
热议问题