[英]Presenting and dismissing a modal view in ios 7
我有一个视图控制器,上面有一个按钮。 该按钮是隐私政策。 当它被点击时,它会转到正确的IBAction,我创建了隐私控制器。
- IBAction ...
{
PrivacyPolicyViewController *privacy = [[PrivacyPolicyViewController alloc] init];
.....
}
我想创建一个隐私控制器的模态视图,它有一个向上动画的UIWebView和一个用于在ios 7中关闭它的后退按钮。我在网上看到的所有方式都是ios 6并且似乎已被弃用。
使用这样的东西:
// assuming your controller has identifier "privacy" in the Storyboard
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
PrivacyPolicyViewController *privacy = (PrivacyPolicyViewController*)[storyboard instantiateViewControllerWithIdentifier:@"privacy"];
// present
[self presentViewController:privacy animated:YES completion:nil];
// dismiss
[self dismissViewControllerAnimated:YES completion:nil];
[self presentmodalviewcontroller:vc];
已被弃用 。
你可以尝试
[self presentViewController:viewController animated:YES completion:nil];
它会为你工作..
如果您使用的是Storyboard,则可以使用segue来呈现模态视图控制器,并以编程方式执行。
[self performSegueWithIdentifier:@"toNewView" sender:self];
这是一个很好的干净方法,因为您不必导入.h文件来实例化presentViewController
方法的第二个控制器对象。
要解雇它,你只需使用展开segue 。
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
taskQueeDetails *privacy = (taskQueeDetails*)[storyboard instantiateViewControllerWithIdentifier:@"taskQueeDetails"];
// Present the modal
[self presentViewController:privacy animated:YES completion:nil];
使用代码并更改字符串instantiateViewControllerWithIdentifier:@“taskQueeDetails”]; 它会工作正常
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.