如果需要,如何重新创建主故事板 [英] How to re-create a mainstoryboard if needed

查看:26
本文介绍了如果需要,如何重新创建主故事板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个记事卡应用程序,我需要能够根据需要多次制作新的记事卡.我想这样做,这样用户就不会受到一定数量的便笺卡的限制.如果他们愿意,我需要知道如何创建新的视图控制器(或记事卡).所以他们创建的页面可以是相同的,但新的记事卡不能与最后一张记事卡的视图相同,否则它不会是他们创建的新的.为了切入正题,我正在尝试为创建的新记事卡创建一个新视图.

I am creating a notecards app and I need to be able to make a new notecard as many times as I want. I want to do this so the user is not limited to an amount of note cards. I need to know how I would create a new view controller (or note card) if they want. So they creating page can be the same but the new note card cant be the same view as the last note card otherwise it wont be the new one they created. To get to the point I am trying to create a new view for a new notecard that was created.

推荐答案

将故事板中的场景视为模板.当您从故事板调用视图控制器时,您会获得一个新副本.

Think of a scene in a storyboard as a template. When you invoke a view controller from a storyboard, you get a new copy.

假设你的应用有一个主视图控制器,上面有一个创建笔记卡"按钮.您可以将该按钮连接到 IBAction,该 IBAction 实例化并显示您的便笺卡视图控制器的新副本.IBAction 方法可能如下所示:

So say your app has a master view controller with a "create note card" button on it. You could connect that button to an IBAction that instantiates and displays a new copy of your note card view controller. The IBAction method might look like this:

@IBAction func createNoteCard(UIButton sender)
{
  //Create a new instance of a Note card view controller
  let newCard = 
    self.storyboard.instantiateViewControllerWithIdentifier("NoteCard")

  //Put your code to configure the view controller here.

  //Display the new note card view controller to the screen
  self.presentViewController(newCard, animated: true)
}

这篇关于如果需要,如何重新创建主故事板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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