当 iOS 中没有网络/互联网连接时,如何禁用按钮?
问问题
392 次
2 回答
3
查看 Apple 的可达性代码。
http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html
并像这样使用它:
Reachability *reachabilityInstance = [[Reachability reachabilityForInternetConnection] retain];
[reachabilityInstance startNotifier];
NetworkStatus networkStatus = [reachabilityInstance currentReachabilityStatus];
BOOL connected = (networkStatus==ReachableViaWiFi || networkStatus==ReachableViaWWAN);
于 2011-09-02T12:22:13.273 回答
1
您可以在需要时简单地隐藏一个按钮
[button setHidden:YES];
于 2011-09-02T12:44:43.630 回答