【问题标题】:Display contact address in ios using xamarin使用 xamarin 在 ios 中显示联系人地址
【发布时间】:2018-04-24 19:48:43
【问题描述】:

xamarin 的绝对初学者。 按照以下教程尝试,只需单击一个按钮即可显示联系人列表,选择一个联系人,然后在屏幕上显示名字、姓氏和地址。 https://github.com/xamarin/recipes/tree/master/Recipes/ios/shared_resources/contacts/choose_a_contact

设法获取要显示的名字和姓氏,但无法获取地址。不断报错

Foundation.MonoTouchException: Objective-C exception thrown.  Name: CNPropertyNotFetchedException Reason: A property was not requested when contact was fetched.    

contanct.PostalAddresses

这是sn-p的代码:-

partial void UIButton197_TouchUpInside(UIButton sender)
    {

        // Create a new picker
        var picker = new CNContactPickerViewController();

        // Select property to pick
        picker.DisplayedPropertyKeys = new NSString[] { CNContactKey.GivenName, CNContactKey.FamilyName, CNContactKey.PostalAddresses };

        // Respond to selection
        var pickerDelegate = new ContactPickerDelegate();
        picker.Delegate = pickerDelegate;

        pickerDelegate.SelectionCanceled += () => {
             SelectedContact1.Text = "";
        };

        pickerDelegate.ContactSelected += (contact) => {
            SelectedContact1.Text = contact.GivenName;
            SelectedContact2.Text = contact.FamilyName;
            SelectedContact3.Text = contact.PostalAddresses
        };

        pickerDelegate.ContactPropertySelected += (property) => {
            SelectedContact1.Text = property.Value.ToString();
        };

        // Display picker
        PresentViewController(picker, true, null);
    }

我错过了什么吗?

【问题讨论】:

    标签: ios xamarin xamarin.ios contact contacts-framework


    【解决方案1】:

    如果其他人遇到类似问题,似乎已经解决了这个问题。

    解决方案是完全关闭 mac 上的 Visual Studio 并重新打开它。 最初,我正在停止该项目并重新构建。可能是一个错误,但我的更改没有被拾取。

    一个简单的重新启动将其重新启动

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-01
      • 1970-01-01
      • 2015-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-12
      相关资源
      最近更新 更多