有谁知道如何使用 UISearchBar 搜索 MKMapView 上的注释吗?

发布于 2024-10-28 11:31:41 字数 118 浏览 0 评论 0原文

我已经搜索了几个小时,但什么也没找到。

还有人可以告诉我他们是否知道如何将分组的 uiTableView 中的单元格链接到某个 DetailView 并将不同的单元格链接到另一个 DetailView 吗?

I've searched for hours and I found Nothing

Also can anyone tell me if they know how to link a cell in grouped uiTableView to a certain DetailView and link a different cell to another DetailView?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我不是你的备胎 2024-11-04 11:31:41

对于地图,如果这是我的注释,我会将搜索代码放在哪里。

- (void)viewDidLoad {
    [super viewDidLoad];

    [mapView setMapType:MKMapTypeStandard];
    [mapView setZoomEnabled:YES];
    [mapView setScrollEnabled:YES];


    // Central Alabama Chapter

    MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } }; 
    region.center.latitude = 33.45606;
    region.center.longitude = -86.83078;
    region.span.longitudeDelta = 0.01f;
    region.span.latitudeDelta = 0.01f;

    [mapView setRegion:region animated:YES]; 

    [mapView setDelegate:self];

    DisplayMap *ann = [[DisplayMap alloc] init]; 
    ann.title = @"Central Alabama Chapter";
    ann.subtitle = @"721 Hillmoor Lane Homewood, Alabama 35209"; 
    ann.coordinate = region.center; 
    [mapView addAnnotation:ann];


    // Walnut Ridge Fire Department

    MKCoordinateRegion region1 = { {0.0, 0.0 }, { 0.0, 0.0 } }; 
    region1.center.latitude = 36.11493;
    region1.center.longitude = -90.95695;
    region1.span.longitudeDelta = 0.01f;
    region1.span.latitudeDelta = 0.01f;



    DisplayMap *ann1 = [[DisplayMap alloc] init]; 
    ann1.title = @"Walnut Ridge Fire Department";
    ann1.subtitle = @"3217 Highway 67 # B, Walnut Ridge, AR"; 
    ann1.coordinate = region1.center; 
    [mapView addAnnotation:ann1];

对于 UITableView Grouped,如果我的代码如下所示,我将在哪里以及如何使用该代码:

- (void)viewDidLoad {
    [super viewDidLoad];

    //Initialize the array.
    listOfItems = [[NSMutableArray alloc] init];

    NSArray *sectionOneArray = [NSArray arrayWithObjects:@"Mission Statement", @"Become a Member", @"Bible Ministries", @"FCFi on Facebook", @"Chapter Kit (PDF)", @"Corporate Members", @"FDIC Indianapolis", @"9/11/2001", nil];

    NSArray *sectionTwoArray = [NSArray arrayWithObjects:@"About", @"Developer", nil];

    NSArray *websiteArray = [NSArray arrayWithObjects:@"FCFi Website", nil];

    [listOfItems addObject:sectionOneArray];
    [listOfItems addObject:sectionTwoArray];
    [listOfItems addObject:websiteArray];

    //Set the title
    self.navigationItem.title = @"More";
}

For the Map, Where would I put the Search Code and at if this is my annotations.

- (void)viewDidLoad {
    [super viewDidLoad];

    [mapView setMapType:MKMapTypeStandard];
    [mapView setZoomEnabled:YES];
    [mapView setScrollEnabled:YES];


    // Central Alabama Chapter

    MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } }; 
    region.center.latitude = 33.45606;
    region.center.longitude = -86.83078;
    region.span.longitudeDelta = 0.01f;
    region.span.latitudeDelta = 0.01f;

    [mapView setRegion:region animated:YES]; 

    [mapView setDelegate:self];

    DisplayMap *ann = [[DisplayMap alloc] init]; 
    ann.title = @"Central Alabama Chapter";
    ann.subtitle = @"721 Hillmoor Lane Homewood, Alabama 35209"; 
    ann.coordinate = region.center; 
    [mapView addAnnotation:ann];


    // Walnut Ridge Fire Department

    MKCoordinateRegion region1 = { {0.0, 0.0 }, { 0.0, 0.0 } }; 
    region1.center.latitude = 36.11493;
    region1.center.longitude = -90.95695;
    region1.span.longitudeDelta = 0.01f;
    region1.span.latitudeDelta = 0.01f;



    DisplayMap *ann1 = [[DisplayMap alloc] init]; 
    ann1.title = @"Walnut Ridge Fire Department";
    ann1.subtitle = @"3217 Highway 67 # B, Walnut Ridge, AR"; 
    ann1.coordinate = region1.center; 
    [mapView addAnnotation:ann1];

For the UITableView Grouped, where and how would i use that code if the code I have Looks like this:

- (void)viewDidLoad {
    [super viewDidLoad];

    //Initialize the array.
    listOfItems = [[NSMutableArray alloc] init];

    NSArray *sectionOneArray = [NSArray arrayWithObjects:@"Mission Statement", @"Become a Member", @"Bible Ministries", @"FCFi on Facebook", @"Chapter Kit (PDF)", @"Corporate Members", @"FDIC Indianapolis", @"9/11/2001", nil];

    NSArray *sectionTwoArray = [NSArray arrayWithObjects:@"About", @"Developer", nil];

    NSArray *websiteArray = [NSArray arrayWithObjects:@"FCFi Website", nil];

    [listOfItems addObject:sectionOneArray];
    [listOfItems addObject:sectionTwoArray];
    [listOfItems addObject:websiteArray];

    //Set the title
    self.navigationItem.title = @"More";
}
近箐 2024-11-04 11:31:41

搜索注释 -

这取决于您想要如何搜索注释,如果您想按标题搜索它,那么首先使用 MKMapView 的注释属性获取所有注释 -

NSArray *arr = [mapView annotations];

for(int i=0; i<[arr count]; i++)
{ 
     MKAnnotation *ann = [arr objectAtIndex:i];
     if([ann.title isEqualToString:[searchBar text]])
     {
         //do what you want to do after getting a annotation
     }
}

UITableView -

如果您想点击单元格上的链接,然后您可以在

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

组表中执行此操作,首先检查indexPath.section,然后检查indexPath.row。

search annotation-

It depends on by how you want to sear an annotation, if you want to search it by title then first get all the annotation by using annotation property of MKMapView as -

NSArray *arr = [mapView annotations];

for(int i=0; i<[arr count]; i++)
{ 
     MKAnnotation *ann = [arr objectAtIndex:i];
     if([ann.title isEqualToString:[searchBar text]])
     {
         //do what you want to do after getting a annotation
     }
}

UITableView -

If you want to link on tap on cell then you can do it in

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

for group table first check for indexPath.section and then check for indexPath.row .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文