Xamarin.ios Monotouch mapkit mkannotation集合出现错误

Xamarin.ios Monotouch mapkit mkannotation集合出现错误,xamarin.ios,mapkit,mkannotation,xamarin,pins,Xamarin.ios,Mapkit,Mkannotation,Xamarin,Pins,monotouch又名xamarin ios的新功能。试图让一个健壮的mapkit工作,它可以占用许多管脚。用我从各种来源拼凑而成的基本示例进行实验 正在获取一个偶发的SIGSEGV错误。当点击管脚以显示一个有时有效有时无效的警报框时,看起来像是某种内存错误 我不确定我错在哪里。这样做对吗?这是密码 使用系统; 使用系统图; 使用单调的基础; 使用MonoTouch.UIKit; 使用MonoTouch.MapKit; 使用MonoTouch.CoreLocation; 使用System.Col

monotouch又名xamarin ios的新功能。试图让一个健壮的mapkit工作,它可以占用许多管脚。用我从各种来源拼凑而成的基本示例进行实验

正在获取一个偶发的SIGSEGV错误。当点击管脚以显示一个有时有效有时无效的警报框时,看起来像是某种内存错误

我不确定我错在哪里。这样做对吗?这是密码

使用系统;
使用系统图;
使用单调的基础;
使用MonoTouch.UIKit;
使用MonoTouch.MapKit;
使用MonoTouch.CoreLocation;
使用System.Collections.Generic;
名称空间单视图
{
公共部分类SingleViewController:UIViewController
{
公共SingleViewController():基(“SingleViewController”,null)
{
}
私人定位服务;
私有MKMapView mapView;
列表引脚=新列表();
公共覆盖无效ViewDidLoad()
{
base.ViewDidLoad();
//一系列贴图点的示例
添加(新的基本坐标表示法(新的位置坐标2d(37.766995,-122.419580),“h”,“sub1”,“id1”);
添加(新的基本坐标表示法(新的位置坐标2d(37.776880,-122.418485),“i”,“sub2”,“id2”);
添加(新的基本坐标表示法(新的位置坐标2d(37.786775,-122.417390),“j”,“sub3”,“id3”);
添加(新的基本坐标表示法(新的位置坐标2d(37.796685,-122.416283),“k”,“sub4”,“id4”);
var currentLocation=new LocationService().GetCurrentLocation();
var visibleRegion=BuildVisibleRegion(当前位置);
mapView=BuildMapView(真);
SetRegion(visibleRegion,true);
this.View.AddSubview(mapView);
//我有一个模糊的想法,即当用户在屏幕上移动时,此委托有助于重新绘制PIN
Delegate=新的MapViewDelegate();
//此pin有时具有激活警报的工作调用,有时则没有
var testAnnotationX=新的基本坐标表示法(新的坐标系2D(37.786999,-122.500222),
“在viewdidload中制造”、“外部”、“id5”);
mapView.AddAnnotation(testAnnotationX);
//这种别针收集有时也有效,但大多数情况下无效
AddAnnotations(pins.ToArray());
}
私有MKMapView BuildMapView(bool showUserLocation)
{
var view=new MKMapView()
{
ShowsUserLocation=showUserLocation,
};
view.Delegate=新的MapViewDelegate();
var testAnnotationY=新的基本坐标系(新的坐标系2D(37.800000,-122.450777),
“在buildmapview中制作”、“内部”、“id6”);
view.AddAnnotation(testAnnotationY);
view.SizeToFit();
view.Frame=新矩形F(0,0,this.view.Frame.Width,this.view.Frame.Height);
返回视图;
}
受保护的类MapViewDelegate:MKMapViewDelegate{
受保护的字符串注释标识符=“基本注释”;
UIButton detailButton;//避免GC
公共覆盖MKAnnotationView GetViewForAnnotation(MKMapView mapView、NSObject annotation)
{
if(注释为MKUserLocation)返回null;//忽略用户标记
annotationIdentifier=(注释为BasicPanNotation).Id;
//请尝试将注释视图出列
MKAnnotationView annotationView=mapView.DequeueReusableAnnotation(annotationIdentifier);
//如果我们无法将一个退出队列,请创建一个新的
if(annotationView==null)
{
annotationView=新的MKPinAnnotationView(注释,注释标识符);
//annotationView.RightCalloutAccessoryView=新建UIButton(UIButtonType.DetailDisclosure);//-不需要,因为它位于底部??
//配置注释视图属性
annotationView.CanShowCallout=true;
(注释视图为MKPinAnnotationView)。AnimatesDrop=true;
(注释视图作为MKPinAnnotationView.PinColor=MKPinAnnotationColor.Green;
annotationView.Selected=true;
//您可以添加附件视图;在本例中,右侧有一个按钮,左侧有一个图像
detailButton=UIButton.FromType(UIButtonType.DetailDisclosure);
detailButton.TouchUpInside+=(s,e)=>{
Console.WriteLine(“单击”);
新建UIAlertView(“已单击批注”、“已单击”+
(注释为MKAnnotation.Coordinate.Latitude.ToString()+“,”+
(注释为MKAnnotation).Coordinate.Longitude.ToString(),null,“OK”,null).Show();
};
annotationView.RightCalloutAccessoryView=detailButton;
}
else//如果我们将一个队列中的一个队列排出来以供重用,则将注释分配给它
annotationView.Annotation=注释;
/*
//配置注释视图属性
annotationView.CanShowCallout=true;
(注释视图为MKPinAnnotationView)。AnimatesDrop=true;
(注释视图作为MKPinAnnotationView.PinColor=MKPinAnnotationColor.Green;
annotationView.Selected=true;
*/
//修正和取消注释
//annotationView.LeftCalloutAccessoryView=新U
0   singleview                          0x00091eac mono_handle_native_sigsegv + 284
1   singleview                          0x00005788 mono_sigsegv_signal_handler + 248
2   libsystem_c.dylib                   0x938658cb _sigtramp + 43
3   ???                                 0xffffffff 0x0 + 4294967295
4   UIKit                               0x0274f258 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
5   UIKit                               0x02810021 -[UIControl sendAction:to:forEvent:] + 66
6   UIKit                               0x0281057f -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 578
7   UIKit                               0x0280f6e8 -[UIControl touchesEnded:withEvent:] + 546
8   UIKit                               0x0277ecef -[UIWindow _sendTouchesForEvent:] + 846
9   UIKit                               0x0277ef02 -[UIWindow sendEvent:] + 273
10  UIKit                               0x0275cd4a -[UIApplication sendEvent:] + 436
11  UIKit                               0x0274e698 _UIApplicationHandleEvent + 9874
12  GraphicsServices                    0x04d40df9 _PurpleEventCallback + 339
13  GraphicsServices                    0x04d40ad0 PurpleEventCallback + 46
14  CoreFoundation                      0x012bfbf5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
15  CoreFoundation                      0x012bf962 __CFRunLoopDoSource1 + 146
16  CoreFoundation                      0x012f0bb6 __CFRunLoopRun + 2118
17  CoreFoundation                      0x012eff44 CFRunLoopRunSpecific + 276
18  CoreFoundation                      0x012efe1b CFRunLoopRunInMode + 123
19  GraphicsServices                    0x04d3f7e3 GSEventRunModal + 88
20  GraphicsServices                    0x04d3f668 GSEventRun + 104
21  UIKit                               0x0274bffc UIApplicationMain + 1211
22  ???                                 0x0f4d71ad 0x0 + 256733613
23  ???                                 0x0f4d4e40 0x0 + 256724544
24  ???                                 0x0f4d4a48 0x0 + 256723528
25  ???                                 0x0f4d4b9e 0x0 + 256723870
26  singleview                          0x00009b52 mono_jit_runtime_invoke + 722
27  singleview                          0x0016d02e mono_runtime_invoke + 126
28  singleview                          0x00171224 mono_runtime_exec_main + 420
29  singleview                          0x00176615 mono_runtime_run_main + 725
30  singleview                          0x000671e5 mono_jit_exec + 149
31  singleview                          0x00204fd4 main + 1988
32  singleview                          0x00002b75 start + 53

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
 a fatal error in the mono runtime or one of the native libraries 
 used by your application.
=================================================================