Mal*_*loc 1 storyboard ios segue
当我使用segues推送视图(直接通过在故事板上拖动它)时,它工作正常,并加载下一个视图.但是,当我尝试以编程方式实现所有这些以在我点击PIN的右箭头(在地图中)时推送视图时,我有点困惑:
编辑
-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
NSLog(@"calloutAccessoryControlTapped: enseigneDeLaStation");
[self performSegueWithIdentifer:@"You identifier" sender:self];
}
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误:
Receiver Type 'MyFirstViewController' for instance message does not declare a method with selector performSegueWithIdentifer:sender:
Run Code Online (Sandbox Code Playgroud)
你必须使用UIViewControllers实例方法performSegueWithIdentifier:sender:.它以编程方式从视图控制器的storyboard文件中启动具有指定标识符的segue.
这是文档.
示例代码是:(假设您在视图控制器中调用它.
[self performSegueWithIdentifier:@"Your identifier" sender:self];
Run Code Online (Sandbox Code Playgroud)
所以对于你的代码,它将是:
-(IBAction)goToNextView{
NSLog(@"The button is clicked");
[self performSegueWithIdentifier:@"Your identifier" sender:self];
}
Run Code Online (Sandbox Code Playgroud)
不要忘记在界面构建器中设置segue标识符.另外,请确保在代码和界面构建器中具有相同的标识符.
| 归档时间: |
|
| 查看次数: |
9240 次 |
| 最近记录: |