简体   繁体   English

Xcode 6界面构建器不显示自定义类

[英]Xcode 6 interface builder does not show custom class

I have an error in my Xcode 6.3 interface builder. 我的Xcode 6.3界面构建器中有错误。 When i create a new custom class and want to add it to interface builder custom class field. 当我创建一个新的自定义类,并希望将其添加到界面构建器自定义类字段。 It is not available. 它不可用。 I do use Swift as languag. 我确实使用Swift作为语言。

What I tried: 我尝试了什么:

  • delete derived data 删除派生数据
  • reinstall Xcode 重新安装Xcode
  • cleand project 清洁项目
  • created new project 创建了新项目
  • Class name is same as file name 类名与文件名相同
  • Superclass and interface builder class are the same 超类和接口构建器类是相同的

Nothing worked out ;-( Any idea what it could be ? 什么都没有成功;-(不知道它可能是什么?

在此输入图像描述

在此输入图像描述

在此输入图像描述

I had the same issue and thought it as a bug. 我有同样的问题,并认为它是一个错误。 But it was my misunderstanding. 但这是我的误解。

What actually happens is: 实际发生的是:

Custom Class drop down list shows only those custom classes which are subclasses of currently selected object's class. “自定义类”下拉列表仅显示那些是当前所选对象类的子类的自定义类。

For example, if we have imageview object in xib and after selecting it, when we see custom class drop down list, it'll show only custom classes inherited from (subclass of) UIImageView. 例如,如果我们在xib中有imageview对象并且在选择它之后,当我们看到自定义类下拉列表时,它将仅显示从(子类)UIImageView继承的自定义类。

What I was doing wrong was looking for those custom classses which are subclasses of UIView. 我错误的是寻找那些属于UIView的子类的自定义类。

In your case, it might be, not 100% sure, happening due to your TimerCVC is a subclass of UICollectionViewController instead of UIViewController. 在您的情况下,由于您的TimerCVC是UICollectionViewController的子类而不是UIViewController,因此可能不是100%确定。

TimerCVC is not a subclass of UIViewController TimerCVC不是UIViewController的子类

Press ctrl-n -> on the left panel choose iOS ->Source -> Cocoa Touch Class -> from the dropdown menu choose UIViewController -> And then fill the name field (automatically Xcode autocomplete with ViewController on the end). 按左侧面板上的ctrl-n - >选择iOS - > Source - > Cocoa Touch Class - >从下拉菜单中选择UIViewController - >然后填写名称字段(最后用ViewController自动Xcode自动完成)。

It should look like this 它看起来应该是这样的

import UIKit

class TimerViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM