简体   繁体   English

ViewController在Main.Storyboard中彼此重叠

[英]ViewControllers overlapping each other in Main.Storyboard

I've two ViewControllers in Main.Storyboard , entry point ViewController have green background, and another is red background. 我在Main.Storyboard有两个ViewControllers ,入口点ViewController具有绿色背景,另一个是红色背景。 At the button click of first ViewController it should show second ViewController , but the first and second ViewControllers are overlapping each other and both ViewControllers Buttons are clickable. 单击第一个ViewController的按钮时,它应该显示第二个ViewController ,但是第一个和第二个ViewControllers彼此重叠,并且两个ViewControllers按钮都是可单击的。

Ist View Controller,宾果按钮

Ist view controller (green), bingo is the UIButton Ist视图控制器(绿色),宾果是UIButton

在此处输入图片说明

2nd view controller (red), hello is the UIButton On the click event of the button in first view controller is : 第二个视图控制器(红色),您好是UIButton在第一个视图控制器中,按钮的click事件是:

MViewController *mvc = [self.storyboard instantiateViewControllerWithIdentifier:@"mvc"];
    [self presentViewController:mvc animated:YES completion:nil];

Try this if its a push segue : 如果尝试推送,请尝试以下方法:

  MViewController *mvc = [self.storyboard instantiateViewControllerWithIdentifier:@"mvc"];
 [self.navigationController pushViewController:mvc animated:YES];

And you should take one navigation controller and assign it as initial view and make green view the root view. 然后,您应该使用一个导航控制器并将其分配为初始视图,并使绿色视图成为根视图。 Delete the default root view controller comes with it. 删除它附带的默认根视图控制器。

You can write this code in the action block of bingo button 您可以在宾果按钮的操作块中编写此代码

{

let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)

let redVC = storyBoard.instantiateViewControllerWithIdentifier("**RedViewControllerSID**") as RedViewController

self.presentViewController(redVC, animated:true, completion:nil)

}

go storyboard and create Storyboard ID as RedViewControllerSID 转到情节提要并创建情节提要ID为RedViewControllerSID

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM