0
嗨can some1 plz幫助我....detailButton無法推送信息。推頁面總是有空標籤
問題是這樣的:一切似乎沒事..我能夠推到另一個頁面,一旦我點擊detailButton。但是,我能夠推送的頁面始終只是一個沒有任何值傳遞到標籤的視圖。我在視圖中的所有標籤都沒有內容..我在這裏做錯了什麼或錯誤的概念嗎?
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
BOOL isRed = NO;
//BOOL isPurple = YES;
if([annotation isKindOfClass:[MyAnnotation2 class]])
isRed = YES;
MKPinAnnotationView *pinView = nil;
if(isRed) {
static NSString *redPin = @"redPin";
pinView = (MKPinAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier:redPin];
if (!pinView) {
pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:redPin] autorelease];
pinView.pinColor = MKPinAnnotationColorRed;
pinView.animatesDrop = YES;
pinView.canShowCallout = YES;
UIButton *detailButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinView.rightCalloutAccessoryView = detailButton;
}
else{
pinView.annotation = annotation;
}
}
else {
static NSString *greenPin = @"greenPin";
pinView = (MKPinAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier:greenPin];
if (!pinView) {
pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:greenPin] autorelease];
pinView.pinColor = MKPinAnnotationColorGreen;
pinView.animatesDrop = NO;
pinView.canShowCallout = YES;
UIButton *detailButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinView.rightCalloutAccessoryView = detailButton;
}
}
return pinView;
}
//
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
NSLog(@"calloutAccessoryControlTapped");
if (self.patientDetailsViewController == nil) {
self.patientDetailsViewController = [[[PatientDetailsViewController alloc] initWithNibName:@"PatientDetailsViewController" bundle:nil] autorelease];
}
MyAnnotation2 *selectedObject = (MyAnnotation2 *)view.annotation;
_patientDetailsViewController.nric = selectedObject.title;
NSLog(@"%@",_patientDetailsViewController.nric);
[self.navigationController pushViewController:_patientDetailsViewController animated:YES];
}
對不起,我是一個菜鳥,所以我逼債很懂はü意味着通過實施calloutAccessoryControlTapped ... u能闡述升技更多.. 而在我的委託方法我有這個: MyAnnotation2 * selectedObject = [self.annotation2 objectAtIndex:selectedIndex];我還需要這樣的: MyAnnotation2 * selectedObject = 非常感謝您的幫助! –
嗨安娜,我遵循你的建議,它仍然返回我空值在標籤...請幫助=( Plz看看上面的新代碼謝謝! –
嗨,安娜,thx爲您的幫助!我已經解決它也是..問題是我通過在整個標題作爲nric ...解決它與: NSString * str = selectedObject.title; NSString * newStr = [str substringtringFromIndex:6]; Thx again你的意見不針對=) –