【发布时间】:2013-02-14 10:16:48
【问题描述】:
我(希望)有一个小问题。 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。
也许这只是一个小错误,我没有发现。
【问题讨论】:
-
init 方法,你不是使用 xib 文件吗?像 -initWithNibName:bundle
-
我没有任何 xib 文件,因为我正在使用情节提要
-
但是如果你不告诉加载什么资源文件,sdk怎么知道加载什么?您必须在 initWithNib 方法中给出 xib 文件的名称。使用 InfoViewController *infoView = [[InfoViewController alloc] initWithNibName:@"InfoViewController" bundle:nil];或使用 [self.storyboard instantiateViewControllerWithIdentifier:@"InfoViewController"];
-
两者都不适合我:
doesn't contain a view controller with identifier 'InfoViewController'和Could not load NIB in bundle: 'NSBundle with name 'infoViewController'
标签: ios uibutton mkmapview mkannotation