在我的应用程序中,用户需要输入一些地址信息。
从版本 1.0 开始,我为此提供了一个地址簿按钮。
这在我之前的测试中工作得很好,但现在当我尝试设置 UITextField.Text 属性时,我收到了 SIGSEGV。每当我尝试在 MonoTouches Debug模式下从 PeoplePicker 中选择地址时,都会发生此错误,当我在 iPhone 上尝试时,错误会在设置 TextFields 和推送下一个 ViewController 之间随机发生。
我的代码有什么问题或者是一个错误吗?
//AB按钮事件
addressBook.TouchUpInside += 委托(delegate) {
//创建新的选择器
ABPeoplePickerNavigationController PP = new ABPeoplePickerNavigationController();
//取消事件
PP.Cancelled += 委托(delegate) {
NavigationController.DismissViewController(true, null);
};
//选择事件
PP.SelectPerson += delegate(对象发送者, ABPeoplePickerSelectPersonEventArgs e) {
//详细人物 View
ABPersonViewController pv = new ABPersonViewController();
//点击属性时的操作
pv.PerformDefaultAction += delegate(object person, ABPersonViewPerformDefaultActionEventArgs ev) {
//如果该属性是一个地址
if(ev.Property.ToString() == "地址"){
字符串 lands = "", orts = "", plzs = "";
尝试{
//从点击的属性中读取详细地址数据
ABMultiValue 地址 = ev.Person.GetAllAddresses();
PersonAddress[] 值 = 地址.GetValues();
土地=值[ev.Identifier.Value].Country.ToString();
orts = 值[ev.Identifier.Value].City.ToString();
plzs = 值[ev.Identifier.Value].Zip.ToString();
}捕获{
Console.WriteLine("Fehlerhafte 地址");
}
//使用新信息设置文本字段
// Debug模式下的iPhone模拟器每次都会在这里崩溃
土地.Text = 土地;
ort.Text = orts;
plz.Text = plzs;
//关闭模块
NavigationController.DismissViewController(true, null);
}
};
//为人物View设置选中的Person
pv.DisplayedPerson = e.Person;
//通过 PeoplePicker Controller 的导航打开人物 View
PP.PushViewController(pv, true);
};
//打开PeoplePicker Controller 模块
NavigationController.PresentViewController(PP, true, null);
};
提前致谢!
最佳答案
刚刚发布的 MonoTouch 6.0.5 修复了类似的 issue .
关于xamarin.ios - 从 ABPeoplePickerModule 设置 TextField 的文本时收到 SIGSEGV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13128170/