如何在 xcode 中的屏幕之间进行切换

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10606255/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:20:48  来源:igfitidea点击:

How to segue between screens in xcode

objective-ciosxcode

提问by Nosrettap

I'm new to XCode/iOS and I'm trying to create a segue between two different screens (one with the letter A on it (a label) and the other with the letter B). I created two basic view controllers on the storyboard and then I added a button to one of them. I then control click and dragged from the button to the other view controller. I choose push. However, when I run it, it doesn't segue. Why not? I've heard about Navigation Controllers, but I don't want a naviagtion bar (with back for example) at the top of my screen, thus I didn't use one.

我是 XCode/iOS 的新手,我正在尝试在两个不同的屏幕(一个带有字母 A(标签),另一个带有字母 B)之间创建一个 segue。我在情节提要上创建了两个基本的视图控制器,然后向其中一个添加了一个按钮。然后我控制单击并从按钮拖动到另一个视图控制器。我选择推。但是,当我运行它时,它不会继续。为什么不?我听说过导航控制器,但我不想要屏幕顶部的导航栏(例如带有背面),因此我没有使用。

回答by Dan F

In order to utilize a push segue, your root view controller needs to be a navigation controller. The only segue you can use without a "master" controller of sorts like that, is a modal segue

为了使用推送转场,您的根视图控制器需要是导航控制器。唯一可以在没有类似“主”控制器的情况下使用的转场是模态转场

回答by gfrigon

You absolutely need a UINavigationControllerif you want your push segue to work.

UINavigationController如果你想让你的 push segue 工作,你绝对需要一个。

However, if you don't want to see the Navigation Bar, you can simply disable it in your navigation controller with the property navigationBarHidden

但是,如果您不想看到导航栏,您可以简单地在导航控制器中使用属性禁用它 navigationBarHidden

If you are using Xcode, this property can be unchecked in the Utilities Bar, Attribute Inspector under the name "Shows Navigation Bar"

如果您使用的是 Xcode,则可以在“实用工具栏”、“属性检查器”名称下的“显示导航栏”中取消选中此属性

回答by Sasha Grievus

Try geeky Lemon video tutorial like this on storyboard basis: http://www.geekylemon.com/WEBPROTECT-xcodestoryboard. You can see them in the site registering or on you tube. I'm too pretty new to x code and i find this series of tutorials vero useful.

在故事板的基础上尝试像这样的极客柠檬视频教程:http: //www.geekylemon.com/WEBPROTECT-xcodestoryboard。您可以在注册站点或您的电子管中看到它们。我对 x 代码太陌生了,我发现这一系列教程非常有用。

回答by tiguero

You need a modal segue if you don't want to use Navigation Controller. Also you probably want to write your custom segue to control the transition between two view controller. You can refer to my post that explain how to segue from one scene to an other here:

如果您不想使用导航控制器,则需要一个模态转场。此外,您可能想要编写自定义 segue 来控制两个视图控制器之间的转换。您可以参考我的帖子,其中解释了如何从一个场景切换到另一个场景:

How do you perform a customized segue (modal segue) from a UIButton in storyboard

您如何从故事板中的 UIButton 执行自定义转场(模态转场)

回答by Cthutu

Here is a very good tutorial on segues. You need to purchase the book/PDF to get the second part of this tutorial, but its a good resource to have if you want to do iOS 5.0 programming.

这是一个非常好的关于 segue 的教程。您需要购买本书/PDF 才能获得本教程的第二部分,但如果您想进行 iOS 5.0 编程,它是一个很好的资源。

http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1

http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1