iOS 8 MKAnnotationView rightCalloutAccessoryView未对齐 [英] iOS 8 MKAnnotationView rightCalloutAccessoryView misaligned

查看:263
本文介绍了iOS 8 MKAnnotationView rightCalloutAccessoryView未对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对iOS内容一般都很陌生,在测试我们的App for iOS 8兼容性时发现了一个问题。
在iOS 7中一切正常,但在iOS 8上,rightCalloutAccessoryView在某些情况下未对齐。

I'm still pretty new to the iOS stuff in general and found a problem while testing our App for iOS 8 compatibility. In iOS 7 everything worked fine but on iOS 8 the rightCalloutAccessoryView is misaligned under certain circumstances.

第一个屏幕截图:正确对齐

First Screenshot: Correctly aligned

第二个屏幕截图:错误对齐

Second Screenshot: Wrong alignment

如您所见,问题发生在InfoWindow标题较长时。但是在iOS 7上并非如此,我找不到任何提及这已经发生变化的事情?

As you can see, the problem takes place when the InfoWindow has a long title. But this was not the case on iOS 7 and I couldn't find anything mentioning this has changed?

我试图了解原因并找到解决方法,但是找不到任何东西。
我们自己可以解决这个问题吗?还是我们必须为Apple提出问题?

I tried to understand why and find a way to resolve this, but couldn't find anything yet. Is this solvable on our own or do we have to file an issue for Apple?

任何帮助/想法都会受到高度赞赏,因为我在某种程度上受到过度挑战有这个问题。

Any help/ideas would be highly appreciated as I'm somehow overchallenged with this problem.

添加MKAnnotationViews的代码

Code which adds the MKAnnotationViews

- (MKAnnotationView *)viewForStation:(id<MKAnnotation>)annotation {
      static NSString *stationIdentifier = @"stao";
      MKAnnotationView *annotationView = [self.mapView dequeueReusableAnnotationViewWithIdentifier:stationIdentifier];
      if (annotationView == nil) {
          annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation           reuseIdentifier:stationIdentifier];
          annotationView.image = [UIImage bundleImageNamed:PIN_IMAGE];
          annotationView.canShowCallout = YES;
          annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
      }
      return annotationView;
}

您可能感兴趣,我(刚才)也将此问题添加到apple.developer.com上的iOS 8测试版部分: https://devforums.apple.com / thread / 242282?tstart = 0

As you may be interested, I (just now) also added this question to the iOS 8 Beta section on apple.developer.com: https://devforums.apple.com/thread/242282?tstart=0

如果我在这里或在apple.developer.com上得到答案,我会反映它,以便我们可以找到它在两个网站上

If I get an answer either here or on apple.developer.com I will reflect it so we can find it on both sites

推荐答案

我通过设置autoresizingmask来解决这个问题,以修复水平bug的垂直bug和frame.size.width

I solved this by setting the autoresizingmask to fix the vertical bug and frame.size.width for the horizontal bug

UIButton* infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[infoButton setFrame:CGRectMake(0, 0, CGRectGetWidth(infoButton.frame)+10, CGRectGetHeight(infoButton.frame))];
[infoButton setAutoresizingMask:UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleTopMargin];
[annotationView setRightCalloutAccessoryView:infoButton];

这篇关于iOS 8 MKAnnotationView rightCalloutAccessoryView未对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆