确定哪个故事板处于活动状态 [英] Identify which Storyboard is active

查看:30
本文介绍了确定哪个故事板处于活动状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要弄清楚如何在任何给定时间确定哪个故事板处于活动状态.我有一个专门的本地化,我需要识别故事板 (UIView),然后根据用户按下的内容以编程方式更改内容.

I need to work out how to identify what storyboard is active at any given time. I have a specialised nativation in which I need to identify the storyboard (UIView) then change things programmatically depending on what the user presses.

  1. 所有故事板都有标识符.
  2. 在根视图的 viewDidLoad 中,我有以下内容.

- (void)viewDidLoad
 self.topViewController = 
    [storyboard instantiateViewControllerWithIdentifier:@"View1"];
{

我想做的是确定用户在哪个情节提要上,并根据媒体执行以下 sudo 代码

What I would like to do is identify which storyboard the user is on and depending on the press do the following sudo-code

- (void)viewDidLoad
if (storyboard.name != RootView)
   self.topViewController = 
    [storyboard instantiateViewControllerWithIdentifier:@"View1"];
{
else if (storyboard.name = View2){
   self.topViewController = 
    [storyboard instantiateViewControllerWithIdentifier:@"View2"];
}

等等....

我已经逐步完成了代码并看到了 StoryboardID,但是我很确定您不打算使用它....

I have step through the code and seen the StoryboardID however it's which I'm pretty sure your not meant to use....

提前致谢杰里米

更新:导航说明

我正在尝试实现 ECSlideViewController,但它正在努力.有效地将幻灯片添加到正确的功能以显示更多选项.所以,这种想法很容易被证明是讨厌的.我有主 UIViewController 然后我在屏幕上有 4 个按钮,它们与其他 UIViewControllersUIViewController代码>等

I'm trying to implement the ECSlideViewController, but It's doing my head in. Effectively adding in the slide to the right function to reveal more options. SO, this thinking was going to be easy turned out icky. I have the master UIViewController<title:HomeView> I then have 4 buttons on the screen which segueway to other UIViewControllers<View1>, UIViewController<View2> etc.

为了在 View1,View2,View3,View4 上产生效果,我需要将类(ECSlideViewController 根据示例)带入 UIViewController.但是,如果我更改以下代码来表示这一点...

In order to produce the effect on View1,View2,View3,View4 I need to bring the class (ECSlideViewController as per the example) into the UIViewController<HomeView>. However If I change the below code to represent this...

self.topViewController = 
    [storyboard instantiateViewControllerWithIdentifier:@"HomeView"]; 

它崩溃是因为它调用了自己.不好,循环编码是不行的.

It crashes because it calls itself. Not good, circular coding is a no no.

但是如果我把它设置成原来的样子

but if I set it to what was originally there

self.topViewController = 
    [storyboard instantiateViewControllerWithIdentifier:@"FirstTop"];

(顺便说一句,firstTop 是示例中使用的视图的标题)

( btw firstTop is the title of the view used with the example)

它可以工作,但随后忽略了 UIViewController

It works but then disregards the UIViewController<HomeView>

这就是为什么我问是否有一种方法可以识别 UIViewControllerself.title(说故事板...我的错),因为我打算这样做如果它位于 UIViewController 上,则在它周围放置条件逻辑,以便不将代码放入.

This is why I asked if there was a way to identify the self.title of the UIViewController(said storyboard...my bad) as I was going to put conditional logic around it in order to not put the code in if it's on the UIViewController<HomeView>.

除非您下载 ECSlideViewController 并开始使用它,否则这真的很难解释.但实际上我只是想测试 self.title.....我想...

It really is hard to explain unless you download the ECSlideViewController and start playing with it. But effectively I just want to test the self.title.....I think...

另一个想法是将逻辑带入四个的 UIViewControllers 并让它在那里工作......但它害怕传递 nil 因为它期待一个标识符......

The other idea was to bring the logic into the UIViewControllers of the four and get it to work there...but It freaks out passing nil as it's expecting an identifier...

希望这是有道理的....

Hope this makes sense....

J.

推荐答案

大家好,

完全抛弃了 ECSlideViewController.我发现一些文章解释了当您有多个 UiViewControllers 没有正确传递数据时它会出现问题.我最终使用了安德鲁斯的建议.http://www.youtube.com/feed/UCJA_puohXgnze8gPaerTeig这对我来说更容易.

Totally ditched ECSlideViewController. I found a few articles explaining that it had issues when you had multiple UiViewControllers not passing data correctly. I ended up using Andrews suggestion. http://www.youtube.com/feed/UCJA_puohXgnze8gPaerTeig It worked for easier for me.

虽然我注意到 Apple 的设计指南,但这通常是不,但我希望他们不会介意.

Although I take note of what the design guidelines Apple have an this is usually a no no, but I'm hoping that they won't mind.

再次感谢大家!

J.

这篇关于确定哪个故事板处于活动状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆