簡體   English   中英

沒有互聯網連接時禁用按鈕

[英]Disable button when no internet connection

當iOS中沒有網絡連接時,如何禁用按鈕?

查看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);

您只需在需要時就隱藏按鈕

[button setHidden:YES];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM