Problem description
I believe everyone will encounter this situation:
Go to the next page, and perform an action on the next page, return to refresh, do not perform an action, return does not refresh. That is, the current page to be implemented as required to refresh the page
Implementation ideas
Define the bool type attribute Isneedrefresh on the current page, and determine in Viewwillappear if a refresh is required. In the second page, rewrite the return button.
Get the CTL for the top page by self.navigationController.viewControllers
Implementing code Current Viewcontroller
@property (nonatomic, assign) BOOL Isneedrefresh; // whether a refresh is required -(void) viewwillappear: (BOOL) animated{ [Super viewwillappear:animated ]; if (Self.isneedrefresh) { NSLog (@ " execute refreshed "); [Self loaddata];} }
#pragmaMark overrides the Return button-(void) leftbtnclicked: (UIButton *) sender{[Self.view Endediting:yes]; [NSObject cancelpreviousperformrequestswithtarget:self]; Uiviewcontroller*ctl = Self.navigationcontroller.viewcontrollers[self.navigationcontroller.viewcontrollers.count-2]; if([CTL Iskindofclass:[addserviceviewcontrollerclass]]) {Addserviceviewcontroller* Ctl2 = (addserviceviewcontroller*) CTL; Ctl2.isneedrefresh=YES; [Self.navigationcontroller Poptoviewcontroller:ctl2 Animated:yes]; }Else{[Self.navigationcontroller popviewcontrolleranimated:yes]; }}
iOS returns refresh data on Demand