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

Xcode 有人知道如何使用UISearchBar搜索MKMapView上的注释吗?,xcode,uitableview,annotations,mkmapview,uisearchbar,Xcode,Uitableview,Annotations,Mkmapview,Uisearchbar,我找了几个小时,什么也没找到 还有谁能告诉我他们是否知道如何将分组uiTableView中的一个单元格链接到某个DetailView,并将另一个单元格链接到另一个DetailView?搜索注释- 这取决于您希望如何搜索注释,如果您希望按标题搜索注释,则首先使用MKMapViewas的注释属性获取所有注释- NSArray *arr = [mapView annotations]; for(int i=0; i<[arr count]; i++) { MKAnnotation

我找了几个小时,什么也没找到

还有谁能告诉我他们是否知道如何将分组uiTableView中的一个单元格链接到某个DetailView,并将另一个单元格链接到另一个DetailView?

搜索注释-

这取决于您希望如何搜索注释,如果您希望按标题搜索注释,则首先使用
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
     }
}

对于组表,首先检查indexPath.section,然后检查indexPath.row。

对于映射,我将把搜索代码放在哪里,如果这是我的注释

- (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分组,如果我的代码如下所示,我将在何处以及如何使用该代码:

- (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";
}
“搜索注释”是什么意思?你的问题不清楚。。。
- (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";
}