[英]Objective-C Showing a view controller on another view controller programmatically
I've got one problem. 我有一个问题。 I have a viewController1 in which I click a button.
我有一个viewController1,在其中单击一个按钮。 When I hit this button, I want it to show another view controller (viewController2) on viewController1 (viewController2 is a little transparent).
当我按下此按钮时,我希望它在viewController1上显示另一个视图控制器(viewController2)(viewController2有点透明)。 I'd like to do this programmatically.
我想以编程方式执行此操作。 I tried this but when I hit the button nothing happens:
我尝试了这个,但是当我按下按钮时什么也没发生:
Notification *newView = [[Notification alloc]initWithNibName:@"Notification" bundle:nil];
[self.navigationController pushViewController:newView animated:YES];
I renamed some variables to make it clearer. 我重命名了一些变量以使其更清晰。 Thanks for answers!
感谢您的回答!
EDIT: Maybe I wasn't clear enough, I want viewController2 to be ONTOP of viewController1 编辑:也许我还不够清楚,我希望viewController2是viewController1的ONTOP
Try below:- 请尝试以下:
Notification *newView = [[Notification alloc]initWithNibName:@"Notification" bundle:nil];
[self presentViewController:newView animated:YES completion:nil];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.