简体   繁体   中英

How to change view in xamarin.ios app when network is available?

Is it possible to change view in iOS app if internet is available then some view will be visible otherwise not and also in middle if internet connectivity went then view should also change according to condition? Let's say I have one view abc , I want to show this view when internet is available and when internet is not available then don't show view abc .

如果您可以检测到Internet是否正常工作,则应该使用“隐藏”属性。

You could use Reachability.cs to detect the connection of the Internet. When your Internet connection updates, it will notice you and you can update the visible status of the view.

You can detect the Internet connection like this:

       Reachability.ReachabilityChanged += UpdateStatus;

Update the visible status here:

        void UpdateStatus (object sender, EventArgs e)
        {
            //Update the visible of your view.
        }

To get the Reachability.cs file and more information, you can refer to the Reachability Sample .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM