我正在使用 MJPopupViewController 在我的应用程序中创建一个 popupView .现在,当按下 popupView 上的按钮时,我需要更新主 View 上的 UILabel。只要按下按钮(最好)或关闭按钮,我就需要更新主 View 上的 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
调用这个方法类按钮点击 Action 调用更新通知 [[NSNotificationCenter defaultCenter] postNotificationName:@"UpdateLbl" object:self]
;
希望对你有帮助:)
关于ios - 在 popupView 中更新主 viewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18118686/