绝对初学者与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
这是代码片段: -
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);
}
我错过了什么吗?
答案 0 :(得分:0)
如果其他人遇到类似的问题,似乎已经解决了这个问题。
解决方案是完全关闭Mac上的visual studio并重新打开它。 最初,我正在停止这个项目,并重建。可能是一个错误,但不是我的变化被拾取。
简单的重新开始将其踢回