菜鸟教程小白 发表于 2022-12-11 22:39:17

ios - 更改pincolor后无法显示注释标题


                                            <p><p>我用这段代码改变了注解的颜色,但是之后标题和副标题就显示不出来了,我该如何解决这个问题?</p>

<p>代码是:</p>

<pre><code>- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id &lt;MKAnnotation&gt;)annotation
{   
static NSString *defaultPinID = @&#34;LYB&#34;;
    MKPinAnnotationView *customPinview = (MKPinAnnotationView *);
    if ( customPinview == nil ) {
      customPinview = [[
                  initWithAnnotation:from reuseIdentifier:defaultPinID] autorelease];
    }
    if (])
      return nil;
    if ([ isEqualToString:@&#34;the first&#34;]) {
      customPinview.pinColor = MKPinAnnotationColorGreen;
    }
    return customPinview;
}
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>在“return customPinview”之前的新行中添加以下代码:</p>

<pre><code>customPinview.canShowCallout = YES;
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 更改pincolor后无法显示注释标题,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/10104164/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/10104164/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 更改pincolor后无法显示注释标题