0

我(希望)有一个小问题。rightCalloutAccessoryView按钮方法。我尝试将其推到navigationcontrolleranother viewcontroller但它不能正常工作。我总是黑屏。已navigationBar禁用

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
// ... code ...
        pinAnnotationView.canShowCallout = YES;
        UIButton *detailButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        [detailButton addTarget:self action:@selector(showDetailView:) forControlEvents:UIControlEventTouchUpInside];
        pinAnnotationView.rightCalloutAccessoryView=detailButton;
// ... code ...
}

按钮:

-(IBAction)showDetailView:(UIButton *)sender
{
    InfoViewController *infoView = [[InfoViewController alloc] init];
    [self.navigationController pushViewController:infoView animated:YES];

    NSLog(@"pushed Button!!!!!!");

}

我的目标:ViewController按下detailButton并推到InfoViewController

也许这只是一个小错误,我没有发现。

4

1 回答 1

1

如果您的 InfoViewController 在情节提要中,那么您需要获取那个,而不是使用 alloc init 创建一个新的。InfoViewController 需要故事板中的标识符,然后您可以像这样实例化它:

InfoViewController *infoView = [self.storyboard instantiateViewControllerWithIdentifier:@"InfoViewController"];
于 2013-02-14T15:56:30.463 回答