Cra*_*ore 1 uiviewcontroller ios
我试图从我的App Delegate访问当前视图.在我的app委托中,有一个定时事件,每30秒访问一个远程服务器.如果它发现需要更新当前数据,我需要它在当前视图上显示进度显示"请等待"模式弹出窗口.
我想使用DejalActivityView在当前活动视图上显示"Please Wait"窗口,但是它需要当前活动视图作为输入参数,我找不到从App Delegate获取它的方法.
Self.Window.RootViewController返回Null,没有当前视图或UIViewController可见,我可以从委托中找到.
任何帮助深表感谢.
而不是这样做,您需要使用不同的架构,如通知.
在AppDelegate中,您将要执行此操作,请将其替换为:
[[NSNotificationCenter defaultCenter] postNotificationName:@"showPleaseWaitAlert" object:nil];
Run Code Online (Sandbox Code Playgroud)
然后,在视图控制器中实现这样的方法:
-(void)showPleaseWait {
//Show your dialog here
}
Run Code Online (Sandbox Code Playgroud)
然后,在类似的方法中viewDidLoad,执行以下操作:
[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showPleaseWait) name:@"showPleaseWaitAlert" object:nil]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
269 次 |
| 最近记录: |