How do I disable a button when there is no connection to a netw开发者_StackOverflowork / internet in iOS?
Check out the reachability code from Apple.
http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html
and use it like this:
Reachability *reachabilityInstance = [[Reachability reachabilityForInternetConnection] retain];
[reachabilityInstance startNotifier];
NetworkStatus networkStatus = [reachabilityInstance currentReachabilityStatus];
BOOL connected = (networkStatus==ReachableViaWiFi || networkStatus==ReachableViaWWAN);
You can simply hide a button whenever you need to
[button setHidden:YES];
精彩评论