【发布时间】:2013-03-15 04:39:03
【问题描述】:
我正在做一个带有MKMapView 的应用程序,该应用程序有一个back button UIView,其中包含MKMapView,以便转到main menu,没关系,但是当我想再次加载 UIView 和 MKMapView 我的应用程序崩溃时,它不会给出任何错误,只是崩溃并显示崩溃的机器代码,但它首先说:com.apple.CoreLocation.ConnectionClient.0x1e5d5220 然后是很多机器代码。
崩溃报告在这里:
我必须补充一点,第一次我加载 UIView 它100% 正常工作。
感谢您的帮助。
PS:为什么我说dealloc?,因为我认为像dealloc 这样的操作可能会解决我的问题,并且与第一次运行时一样。
EDIT1:
我的- (void) viewDidLoad; 方法。
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *response = [self sendPostToURL: @"http://hidden.php"
withPost: @"hidden"];
[self tratarXML: response];
yo = @"Posición actual";
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
self.locationManager.distanceFilter = kCLDistanceFilterNone;
[self.mapView setDelegate: self];
[self.mapView setZoomEnabled: NO];
[self.mapView setScrollEnabled: NO];
if ([CLLocationManager locationServicesEnabled])
{
self.locationManager.delegate = self;
self.mapView.showsUserLocation = YES;
[self.mapView setMapType: MKMapTypeStandard];
[self.mapView setUserTrackingMode: MKUserTrackingModeFollowWithHeading animated: NO];
[self.locationManager startUpdatingLocation];
//[self.locationManager startUpdatingHeading];
self.mapView.userLocation.title = yo;
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"Debe activar la localización en esta aplicación para funcionar"
delegate:self
cancelButtonTitle:@"Aceptar"
otherButtonTitles:nil, nil];
[alert show];
}
}
EDIT2: 我的后退按钮代码:
- (IBAction) iniciar: (id)sender
{
if ([iniciar.title isEqualToString:@"Volver"])
{
menuViewController *obj = [[menuViewController alloc] initWithNibName:@"menuViewController" bundle:nil withUser:user];
[self presentViewController:obj animated:YES completion:nil];
}
else
{
// censored
}
我使用的是简单的 *.xib 导航器,而不是情节提要等...
EDIT3:
加载MKMapView UIView的菜单按钮
- (IBAction) TEST: (id)sender
{
mapaViewController *obj = [[mapaViewController alloc] initWithNibName: @"mapaViewController" bundle: nil withUser: user];
[self presentViewController:obj animated:YES completion:nil];
}
【问题讨论】:
-
请在
mapsViewController添加相关代码。 -
如果带有地图视图的控制器嵌入在导航控制器中,当您点击后退按钮时它将被释放(除非您正在做一些事情来保持指向它的强指针)。您可以通过在该控制器中实现 dealloc 来轻松测试这一点,并将日志语句放入其中以查看它是否被调用。
-
@Rikkles 你需要哪个代码?因为它没有告诉我任何行数,而且我第一次使用它时,它总是有效,所以我很困惑它出了什么问题。 @rdelmar 我没有使用任何强指针。 dealloc 方法不起作用,我刚刚输入了
NSLog(@"a");,但我必须在那里做什么?因为我不能释放所有变量,因为 ARC 应该这样做。 :// -
@rokimoki 有两种可能性 1)您的视图以某种方式过度发布 2)某个进程出现在前面,而另一个进程已经在进行。
-
我有一个同步的 POST,(因此线程将等待完成帖子,然后再开始使用新代码) - 但我在所有视图中都有它,只是在
MKMapView UIView中不起作用'不认为它已经过度发布,因为它没有任何意义并且可能是苹果的错误,但我认为错误的可能性是我的代码,顺便说一句,错误代码应该在viewDidLoad和/或initWithNibName:方法中,对吧?
标签: ios uiview mkmapview core-location crash-reports