1
我知道它在很多次之前就被問過了,但我似乎無法得到它。我繪製了我的地圖,添加了註釋,並且我想將註釋按鈕添加到註釋中。在mapview註釋中添加了揭密按鈕
我從我的viewDidLoad方法陣列通過從文本文件
NSURL *dataUrl = [NSURL URLWithString:@"http://nne.ezadspro.co.uk/cms/testmap.txt"];
NSString *fileString = [NSString stringWithContentsOfURL:dataUrl
encoding:NSUTF8StringEncoding
error:nil];
int count = 0;
NSScanner *scanner = [NSScanner scannerWithString:fileString];
eventPoints = [[NSMutableArray array] retain];
Locations *event;
NSString *line;
NSArray *values;
while ([scanner isAtEnd] == NO) {
[scanner scanUpToString:@"\n" intoString:&line];
//skip the first line
if(count > 0) {
values = [line componentsSeparatedByString:@","];
event = [[[Locations alloc] init] autorelease];
event.latitude = [[values objectAtIndex:5] floatValue];
event.longitude = [[values objectAtIndex:6] floatValue];
//event.companyID = [[values objectAtIndex:0]intValue];
event.title = [values objectAtIndex:1];
event.subtitle = [values objectAtIndex:2];
//event.magnitude = [[values objectAtIndex:4] floatValue];
//event.depth = [[values objectAtIndex:5] floatValue];
[eventPoints addObject:event];
}
count++;
if(count == 300) {
//limit number of events to 300
break;
}
}
//UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[mapView addAnnotations: eventPoints];
這工作得很好拉動添加註釋,但就像我說我要添加的按鈕,現在我已經看到了(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)註解{
但是無論我用這種方法做什麼似乎都不起作用,有人可以幫助我嗎?我怎麼得到它的工作(它是怎麼叫?)我不知道
我是相當新的這個所以要簡單,如果你能和虐待儘量不要問太多的問題:)
輝煌.....我知道這是一些愚蠢的.... – 2010-10-15 14:38:13