我(希望)有点问题。 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
。
也许这只是一个小错误,我找不到。
答案 0 :(得分:1)
如果您的InfoViewController在故事板中,那么您需要获取那个,而不是使用alloc init创建一个新的。 InfoViewController需要在故事板中使用标识符,然后您可以将其实例化为:
InfoViewController *infoView = [self.storyboard instantiateViewControllerWithIdentifier:@"InfoViewController"];