Ios6 MKMapView自定义详图索引视图,自动布局iOS 6与iOS 7

Ios6 MKMapView自定义详图索引视图,自动布局iOS 6与iOS 7,ios6,ios7,mkmapview,autolayout,mkannotationview,Ios6,Ios7,Mkmapview,Autolayout,Mkannotationview,嘿,伙计们 如果我在调用视图中使用自动布局,我的应用程序将在iOS 6下的MKMapView上崩溃。在iOS 7上,这很好 - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view { CustomMapAnnotation *annotation = (CustomMapAnnotation *)view.annotation; if([annotation isKindOfCl

嘿,伙计们

如果我在调用视图中使用自动布局,我的应用程序将在iOS 6下的MKMapView上崩溃。在iOS 7上,这很好

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
CustomMapAnnotation *annotation = (CustomMapAnnotation *)view.annotation;

if([annotation isKindOfClass:[CustomMapAnnotation class]]) {
    CustomMapCalloutView *calloutView = [CustomMapCalloutView new];
    calloutView.translatesAutoresizingMaskIntoConstraints = NO;

    calloutView.titleLabel.text = annotation.titleText;
    calloutView.subTitleLabel.text = annotation.subTitleText;
    calloutView.distanceTextLabel.text = annotation.distanceText;

    [view addSubview:calloutView];

    NSDictionary *viewsDictionary = @{@"callOutView": calloutView};
    NSArray *hConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:[callOutView(150)]" options:0 metrics:nil views:viewsDictionary];
    NSArray *vConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:[callOutView(50)]" options:0 metrics:nil views:viewsDictionary];

    NSLayoutConstraint *xConstraint = [NSLayoutConstraint constraintWithItem:calloutView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:view attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0.0];
    NSLayoutConstraint *yConstraint = [NSLayoutConstraint constraintWithItem:calloutView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0];

    [view addConstraint:xConstraint];
    [view addConstraint:yConstraint];

    [view addConstraints:hConstraints];
    [view addConstraints:vConstraints];
}}
控制台显示以下错误:

*在-[MKAnnotationView layoutSublayersOfLayer:],/SourceCache/UIKit_Sim/UIKit-2380.17/UIView.m:5776 2013-10-27中断言失败 13:39:18.519 PartySmarty[9825:907]*由于未捕获而终止应用程序 异常“NSInternalInconsistencyException”,原因:“自动布局” 执行-layoutSubviews后仍然需要。MKAnnotationView的 -layoutsubview的实现需要调用super

谁能告诉我问题出在哪里吗?CustomCallout视图也适用于自动布局,并且我不会在中覆盖布局子视图

这为我指明了正确的方向。我在MKAnnotationView上创建了一个类别,覆盖layoutSubviews方法并调用super方法

这也适用于iOS 7

这为我指明了正确的方向。我在MKAnnotationView上创建了一个类别,覆盖layoutSubviews方法并调用super方法

这也适用于iOS 7

没有帮助我,我不想切换回框架模型:(没有帮助,我不想切换回框架模型:(