我正在努力重建一个简单的VC与一个“现在”按钮,以模式过渡到第二个自定义VC有一个“关闭”按钮。下面是我试图用Swift重新创建的Obj C代码:
- (IBAction)didClickOnPresent:(id)sender {
CustomModalViewController *modalVC = [self.storyboard instantiateViewControllerWithIdentifier:@"customModal"];
modalVC.transitioningDelegate = self;
modalVC.modalPresentationStyle = UIModalPresentationCustom;
[self.navigationController presentViewController:modalVC animated:YES completion:nil];
}
这里是我的密码:
@IBAction func didClickOnPresent(sender: AnyObject) {
let modalVC = self.storyboard?.instantiateViewControllerWithIdentifier("customModal") as! CustomModalViewController
modalVC.transitioningDelegate = self
modalVC.modalPresentationStyle = UIModalPresentationStyle.Custom
self.navigationController?.presentViewController(modalVC, animated: true, completion: nil)
}
由于某些原因,该模型是在原始VC中而不是在第二个VC中提出的。我检查了出口和识别码。知道我做错了什么吗?
最佳答案
您可能是从错误的位置演示。请改为:
self.presentViewController(modalVC, animated: true, completion: nil)