在 UITabBarController 中为 Xcode Storyboard Segue 设置标识符,并获取指向其视图控制器的指针
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11286859/
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
Setting an identifier for an Xcode Storyboard Segue in a UITabBarController, and getting a pointer to its view controller
提问by Aaron Brager
This is my first app using storyboards/segues, and I'm pretty sure the answer to this is easy, but I'll be as thorough as possible in describing my issue.
这是我第一个使用故事板/segues 的应用程序,我很确定这个问题的答案很简单,但我会尽可能彻底地描述我的问题。
I am making a simple app which has a Tab Bar Controller scene and two View Controllers.
我正在制作一个简单的应用程序,它有一个标签栏控制器场景和两个视图控制器。
My app launches by being sent a URL from another app. The application:openURL:sourceApplication:annotation:
method in the app delegate performs some work to determine
我的应用程序通过从另一个应用程序发送一个 URL 来启动。application:openURL:sourceApplication:annotation:
应用程序委托中的方法执行一些工作来确定
- which tab to display first, and
- what information to display on it.
- 首先显示哪个选项卡,以及
- 在上面显示什么信息。
My goal is to use the performSegueWithIdentifier
method (I'm open to alternatives though) from within the AppDelegateto select the tab, and also find a way to send a method to the instance of the view controller created by the storyboard.
我的目标是使用AppDelegate 中的performSegueWithIdentifier
方法(尽管我对替代方案持开放态度)来选择选项卡,并找到一种方法将方法发送到故事板创建的视图控制器的实例。
Issue #1is that I can't set an identifier. When I select the tab "relationship" there are no choices available in the Attributes Inspector (it says "Not Applicable"). How do I set a name for this segue? Can I? Or is there some rule under which UITabBarControllersegues can't be trigger programmatically?
问题 #1是我无法设置标识符。当我选择“关系”选项卡时,属性检查器中没有可用的选项(显示“不适用”)。我如何为这个转场设置一个名称?我可以吗?或者是否有一些规则不能以编程方式触发UITabBarControllersegues?
Issue #2is that I can't find a way to have a pointer to the view controller. Pre-Storyboard I would alloc
and init
a new view controller and then set it up, but here if I do that, it does not get displayed when my app launches (I think this is because Storyboard is displaying a different instance of the same view controller.)
问题 #2是我找不到指向视图控制器的指针的方法。Pre-Storyboard 我会alloc
和init
一个新的视图控制器然后设置它,但如果我这样做,它不会在我的应用程序启动时显示(我认为这是因为 Storyboard 显示的是同一个视图控制器的不同实例。 )
I know this post is long, but I feel like I'm missing something simple. What is it?
我知道这篇文章很长,但我觉得我错过了一些简单的东西。它是什么?
采纳答案by tarheel
Sounds like you need to have your AppDelegate set the entry pointto your storybard.