我正在创建一个记事卡应用程序,我需要能够根据需要多次制作新的记事卡。我想这样做是为了让用户不受笔记卡数量的限制。如果他们愿意,我需要知道如何创建一个新的 View Controller (或记事卡)。因此,他们创建的页面可以相同,但新的记事卡不能与上一张记事卡的 View 相同,否则它不会是他们创建的新记事卡。言归正传,我正在尝试为已创建的新记事卡创建新 View 。
最佳答案
将 Storyboard 中的场景视为模板。当您从 Storyboard 中调用 View Controller 时,您会得到一个新副本。
假设您的应用有一个主视图 Controller ,上面有一个“创建记事卡”按钮。您可以将该按钮连接到一个 IBAction,该 IBAction 实例化并显示您的记事卡 View Controller 的新副本。 IBAction 方法可能如下所示:
@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)
}
关于ios - 如果需要,如何重新创建主 Storyboard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34302838/