问题描述
我有一个项目有两个目标 A 和 B.
I have a project with two targets A and B.
当我打开我的故事板并特别选择一个场景并导航到身份检查器">自定义类">模块"时,
When I open my storyboard and select one scene in particular and navigate to 'identity inspector' > 'custom class' > 'Module',
下拉列表中有一个空白条目(下拉列表不显示 A 或 B).当我选择空白条目时,下拉列表显示无".这是一个问题,因为它会导致我的程序在尝试使用场景时崩溃.
there is a single blank entry in the drop down (the drop down does not display A or B). When I select the blank entry the drop down shows "None". This is a problem because it causes my program to crash when attempting to use the scene.
如果我选择从目标继承模块",正确的目标显示在身份检查器">自定义类">模块"下,但是我的程序在尝试使用场景时仍然会崩溃.
If I select 'Inherit module from target', the correct target displays under 'identity inspector' > 'custom class' > 'Module', however my program will still crash when attempting to use the scene.
类本身可以在身份检查器">自定义类">类"文本框的提前输入中找到.
The class itself is found in the type-ahead of the 'identity inspector' > 'custom class' > 'Class' textbox.
类的名称是 SWRevealController.m(这是一个 obj-c 文件),而我的大部分项目都在 swift 中.
The name of the class is SWRevealController.m (which is an obj-c file) whereas most of my project is in swift.
A 和 B 在身份检查器">自定义类"> 模块下的所有其他场景中显示为可选.我还可以为这些场景选择从目标继承模块",程序不会崩溃.
A and B appear as selectable in every other scene under 'identity inspector' > 'custom class' > Module. I can also select 'inherit module from target' for those scenes and the program does not crash.
我尝试过的其他事情:*在构建阶段">编译源"下手动删除并重新添加 SWRevealController.m*制作一个新的故事板并从头开始放置视图控制器.
Other things I have tried:*manually deleting and re-adding the SWRevealController.m under 'Build Phases' > 'Compiled sources'*making a new storyboard and putting view controllers in from scratch.
main.storyboard 本身是两个目标的一部分.
The main.storyboard itself is part of both targets.
推荐答案
好吧,我所做的对我有用的事情(我不应该做但确实有效)是 4 件事.
OK, what I did that worked for me (which I should not have had to do but it works) was 4 things.
- 进入 SWRevealViewController.m 并添加
@class SWRevealViewControllerSegueSetController;
使 seguesetcontroller 可用于第 2 步.
To make the seguesetcontroller available for step #2.
- 制作一个从 Objective-C 类继承的 swift 文件(什么都不做)
import Foundation
final class MyRevealViewController : SWRevealViewController
{
}
final class MyRevealViewControllerSegueSetController : SWRevealViewControllerSegueSetController
{
}
进入我的故事板并将类从
SWRevealViewController
更改为MyRevealViewControllerSegueSetController
.此时,不同的目标 A 和 B 出现在身份检查员"> 下的下拉列表中.'自定义类' >模块".
Go into my storyboard and change the class from
SWRevealViewController
toMyRevealViewControllerSegueSetController
. At this point, the different targets A and B appear in the drop down under 'identity inspector' > 'custom class' > 'Module'.
我需要将故事板中使用的 Segue 类从 SWRevealViewControllerSegueSetController
更改为 MyRevealViewControllerSegueSetController
I needed to change the Segue classes used in my storyboards from SWRevealViewControllerSegueSetController
to MyRevealViewControllerSegueSetController
这篇关于Xcode 故事板类没有模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!