如果在iOS中没有连接到网络/互联网时,如何禁用按钮?
答案 0 :(得分: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);
答案 1 :(得分:1)
您可以随时隐藏按钮
[button setHidden:YES];