0

私は(うまくいけば)少し問題があります。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!!!!!!");

}

私の目標:をViewController押してdetailButton、に押しInfoViewControllerます。

たぶんそれは私が見つけられない小さな間違いでした。

4

1 に答える 1

1

InfoViewControllerがストーリーボードにある場合は、alloc initを使用して新しいものを作成するのではなく、それを取得する必要があります。InfoViewControllerにはストーリーボードに識別子が必要です。その後、次のようにインスタンス化できます。

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