Navigationcontroller不能正常工作

时间:2013-02-14 10:16:48

标签: ios uibutton mkmapview mkannotation

我(希望)有点问题。 rightCalloutAccessoryView按钮方法。我尝试将navigationcontroller推送到another 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!!!!!!");

}

我的目标:ViewControllerdetailButton并按InfoViewController

也许这只是一个小错误,我找不到。

1 个答案:

答案 0 :(得分:1)

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

InfoViewController *infoView = [self.storyboard instantiateViewControllerWithIdentifier:@"InfoViewController"];