【发布时间】:2011-07-27 01:29:52
【问题描述】:
我已经搜索了几个小时,但我一无所获
还有谁能告诉我他们是否知道如何将分组的 uiTableView 中的单元格链接到某个 DetailView 并将不同的单元格链接到另一个 DetailView?
【问题讨论】:
-
“搜索注释”是什么意思?你的问题不清楚...
标签: xcode uitableview annotations mkmapview uisearchbar
我已经搜索了几个小时,但我一无所获
还有谁能告诉我他们是否知道如何将分组的 uiTableView 中的单元格链接到某个 DetailView 并将不同的单元格链接到另一个 DetailView?
【问题讨论】:
标签: xcode uitableview annotations mkmapview uisearchbar
对于地图,我会将搜索代码放在哪里,如果这是我的注释。
- (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";
}
【讨论】:
搜索注释-
这取决于您要如何搜索注解,如果您想按标题搜索,则首先使用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 。
【讨论】: