0
我有(希望)一個小問題。按鈕方法爲rightCalloutAccessoryView
。我試圖推navigationcontroller
到another viewcontroller
,但它不工作正常。我總是得到一個黑屏。該navigationBar
被禁用Navigationcontroller不能正常工作
- (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 – Luke 2013-02-14 10:24:40
我沒有任何xib文件,因爲我正在使用故事板 – CTSchmidt 2013-02-14 10:33:16
但是如果您不告訴要加載哪個資源文件,sdk將如何知道要加載的內容?您必須在initWithNib方法中提供xib文件的名稱。使用InfoViewController * infoView = [[InfoViewController alloc] initWithNibName:@「InfoViewController」bundle:nil];或者使用[self.storyboard instantiateViewControllerWithIdentifier:@「InfoViewController」]; – 2013-02-14 11:06:09