[英]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.