我正在使用 MJPopupViewController 在我的应用程序中创建一个 popupView .现在,我需要在弹出 View 上按下按钮时更新主视图上的 UILabel。我需要在按下按钮(最好)或关闭按钮时立即更新主视图上的 UILabel。
我已经尝试过 viewWillDisappear 和 viewWillAppear 方法,但似乎都不起作用。
最佳答案
您可以使用 NSNotificationCenter
从当前类调用其他类方法,如下例所示:-
在您的 ViewDidLoad
方法的 MainClass 中添加通知:-
- (void)viewDidLoad
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(UpdateLable:)
name:@"UpdateLbl"
object:nil];
[super viewDidLoad];
}
-(void)UpdateLable:(NSNotification *)notification {
//Update lable code here
}
现在你只需要调用这个方法从你的popupView
类Button click Action for calling update Notification
[[NSNotificationCenter defaultCenter] postNotificationName:@"UpdateLbl" object:self]
;
希望对你有帮助:)
关于ios - 在 popupView 中更新主 viewController 的 Action ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18118686/