首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在ios 5中搜索后触发call out call

在ios 5中搜索后触发call out call
EN

Stack Overflow用户
提问于 2012-05-03 22:56:07
回答 1查看 254关注 0票数 0

我在我的视图中有一个搜索栏,是由用户用来输入一个关键字,并根据这一点进行搜索。为此,我使用了uisearchbar委托。现在地图正在进入关键字搜索的中心,但我也想显示与此相关的调用。我有lat和title,我想这会很有用。代码如下:

代码语言:javascript
复制
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{
     NSLog(@"text %@",searchBar.text);
    NSEnumerator *enumerator = [res objectEnumerator];
    id obj;
    NSString *stringToSearchFor = [searchBar text];
    stringToSearchFor= [stringToSearchFor lowercaseString];
    NSString *searchInThisString = @"";
    while(obj = [enumerator nextObject]){
        searchInThisString = [obj title];
        searchInThisString = [searchInThisString stringByAppendingString:@" "];
        searchInThisString = [searchInThisString stringByAppendingString:[obj address]];
        searchInThisString = [searchInThisString lowercaseString];
        if([searchInThisString rangeOfString:stringToSearchFor].location == NSNotFound ){
            NSLog(@"not found ");
            continue;
        }else{
            NSLog(@"found");

            NSString *lat = [obj latitude];
            NSString *longi = [obj longitude];
            MKCoordinateRegion region = self.gpMapView.region;
            region.center.latitude = [lat doubleValue];
            region.center.longitude = [longi doubleValue];
            id<MKAnnotation> myAnnotation = [self.gpMapView.annotations objectAtIndex:0];
            MKAnnotationView *mkv = [[MKAnnotationView alloc]init];
            [mkv setSelected:YES];
            [self.gpMapView selectAnnotation:myAnnotation animated:YES];
            [self.gpMapView setRegion:region animated:YES];

            break;
        }
    }

我怎么才能触发callout冒泡任何想法呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-05-23 06:53:05

我相信你已经解决了这个问题,但以防万一...根据苹果公司的文件,只有当大头针已经出现在屏幕上时,SelectAnnotation才能工作。

MKMapView类引用> SelectAnnotation如果指定的批注不在屏幕上,因此没有关联的批注视图,则此方法无效。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10433957

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档