ios - 自定义类不显示在属性检查器中

标签 ios objective-c xcode storyboard interface-builder

使用 Storyboard 时,我通常将 Identity Inspector 中的 Custom Class 设置为我的 View 和 View Controller 的类。这次,我创建了一个继承自 UIPageViewController 的基类 (PageViewController),然后创建了另外两个类(ProfilePageViewControllerContextPageViewController) 又继承自 PageViewController

PageViewController 的想法是通过提供 ProfilePageViewControllerContextPageViewController 通用的机制来扩展 UIPageViewController 的功能。到目前为止一切顺利。

然后我将几个 View Controller 拖到界面构建器并将我之前编写的类设置为自定义类(同样,那是 ProfilePageViewControllerContextPageViewController)。

如果我从头开始使用 UIPageViewController,Properties Inspector 将如下所示:

enter image description here

但事实并非如此。

还有一点。我知道如果我拖动 UIPageViewController然后更改自定义类,这将正确显示。然而,ProfilePageViewControllerContextPageViewController 都在 Container Views 中,这几乎意味着 Xcode 自动生成了它们。即:

  1. 我创建了一个父 View Controller
  2. 将两个容器 View 拖入其中
  3. Xcode 自动生成两个UIViewController
  4. 我希望这两个 View Controller 属于自定义类,它是 UIPageViewController 的子类型。

属性检查器显示的只是 View Controller 的属性:

enter image description here

如何显示这些属性?

最佳答案

我花了很多时间和精力尝试做到这一点,事实证明这很简单。

  1. 将页面 View Controller 拖到 Canvas 上;
  2. 更改它的自定义类属性;
  3. Control + 从容器拖动到新 Controller ;
  4. 点击“嵌入”。

Xcode 会自动替换它自动生成的 Controller 。您可以删除它。

关于ios - 自定义类不显示在属性检查器中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24846358/

相关文章:

ios - 每天按设定时间间隔触发本地通知。 (例如,每天上午 10 点至下午 6 点,间隔 5 分钟)

iphone - 从服务器获取数据后如何获取保存数据的文件路径?

Objective-C 获取目录中的文件和子文件夹列表

objective-c - 将字符串转换为 float ,而不使用 c 中的内置函数

xcode - OCLint 无法发现预编译的工作区/项目头

ios - 在 iOS 上运行 ionic 应用程序时出现 NSURLConnection 错误 1100

ios - 在 Swift 中使用 CollectionView 进行网格布局

objective-c - 适用于 iOS 的 Dropbox SDK : How to determine which version you are using?

iphone - 可以将 if 语句放在#define 中吗?

iphone - 如何在相关 View Controller 中获取我的 tabbarcontroller 的选定索引?