Reachability 中未调用通知
我使用了 Andrew's 修改后的 Reachability 类。
-(void)viewDidLoad
[[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(checkNetworkStatus:) name:kReachabilityChangedNotification object:nil];
下载数据时,我关闭 AirPort
。但是 checkNetworkStatus
没有被调用。我是不是错过了什么。请帮我。这个问题让我发疯。提前致谢。
I have used Andrew's modified Reachability class.
-(void)viewDidLoad
[[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(checkNetworkStatus:) name:kReachabilityChangedNotification object:nil];
When data is downloading I turn AirPort
off. But checkNetworkStatus
is not being called. Am I missing something. Please help me. This problem driving me nuts. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您是否告诉可达性实例开始广播通知?
Did you tell the reachability instance to start broadcasting notifications?
将其按此顺序放入
您的视图中并加载
首先注册
然后
发布该通知
put it in this sequence
in ur view did load
First register
then
post that notification
我有完全相同的问题,Apple 的示例效果很好,所以我最终用 Apple 的版本替换了 Reachability 类,一切都很好。这花了我将近2个小时。
只需替换 Apple 示例中的 Reachability.h、.m,一切就应该可以正常工作。
I have exactly the same issue, Apple's example works great, so I end up replace Reachability class with Apple's version, everything works great. This costed me almost 2 hours.
Simply replace your Reachability.h, .m from Apple's example, everything should just worked.
这对我有用(斯威夫特):
This worked for me (Swift):