【问题标题】:Xamarin NetworkReachability SetCallBack method issue after migrating to x64 iOS迁移到 x64 iOS 后的 Xamarin NetworkReachability SetCallBack 方法问题
【发布时间】:2014-12-27 17:38:35
【问题描述】:

将我的 iOS 项目迁移到 x64 后,我遇到了很多错误,我修复了所有错误,只是无法修复以下错误,我在 Xamarin 和 Apple 开发者网站上搜索了很多,但没有解决。

Error CS1061: Type `SystemConfiguration.NetworkReachability' does not contain a definition for `SetCallback' and no extension method `SetCallback' of type `SystemConfiguration.NetworkReachability' could be found. Are you missing an assembly reference? (CS1061)

我还导入了以下参考:

using System;
using System.Net;
using Foundation;
using UIKit;
using SystemConfiguration;
using CoreFoundation;
using CoreServices;

代码是:

NetworkReachability reachability = new NetworkReachability (new IPAddress (new byte [] {169,254,0,0}));
reachability.SetCallback (OnChange); // <-- seems that this method removed from the class But what I should use instead of it ?

请与我分享您的建议。

【问题讨论】:

    标签: ios xamarin.ios xamarin


    【解决方案1】:

    您将希望改用reachability.SetNotification()

    SetCallback() 不再推荐:

    [Advice ("Use SetNotification instead")]
    public bool SetCallback (NetworkReachability.Notification callback)
    {
        return this.SetNotification (callback) == StatusCode.OK;
    }
    

    【讨论】:

    • 这个方法有同样的功能吗?
    • 您从哪里获得所有这些信息? xamarin 网站上的 api 参考在系统配置(monotouch 和 monomac)方面缺乏
    • @krumelur reachability.SetNotification() 我在我的代码中使用过,但它显示错误“setNotification 方法没有重载需要 0 个参数”
    • 我想每次都将 Setcallback 更改为 SetNotification 是不够的,因为在这个演示中 codeproject.com/Tips/870548/… 它使用了 Setcallback 但更改为 SetNotification,它不起作用。
    猜你喜欢
    • 2019-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-24
    • 1970-01-01
    • 1970-01-01
    • 2018-06-14
    • 2011-04-23
    相关资源
    最近更新 更多