【问题标题】:Interface Builder - custom class not showingInterface Builder - 自定义类未显示
【发布时间】:2013-10-14 02:45:04
【问题描述】:

我是一名使用 mac OS X 10.8.5 和 Xcode 5 的 iOS 开发人员。我正在尝试使我的 iPhone 应用程序通用,但我的 viewController 的对象(例如按钮、文本视图等)无法连接到viewController 的类。我尝试将自定义类添加到 viewController,但自定义类会自动返回到 UIViewController(是的,我检查了类的拼写)。自定义类适用于我的 iPhone 故事板,但不适用于我的 iPad 故事板。我还尝试重新启动 Xcode 甚至我的 iMac,但到目前为止还没有工作。

这是我班级的代码(.h 文件):

@interface hackScreen : UIView
@property (retain, nonatomic) IBOutlet UITextView *txtfieldOne;
@property (retain, nonatomic) IBOutlet UITextView *txtfieldTwo;
@property (retain, nonatomic) IBOutlet UITextView *txtfieldThree;
@property (retain, nonatomic) IBOutlet UITextView *txtfieldFour;
@property (retain, nonatomic) IBOutlet UITextView *txtfieldFive;
@property (retain, nonatomic) IBOutlet UITextView *txtfieldSix;
@property (retain, nonatomic) IBOutlet UITextView *txtfieldSeven;
@property (retain, nonatomic) IBOutlet UITextView *DatRandomBinary;
@property (retain, nonatomic) IBOutlet UITextView *leDoneMessage;



- (IBAction)tallStar:(id)sender;
- (void) oneStar;
- (void) tigerStar;
- (void) blackStar;
- (void) pineStar;
- (void) blueStar;
- (void) redStar;
- (void) cloudStar;
- (void) assemblyCode;
- (void) assemblyTwo;
- (void) radioActive;

@end

这是我的 viewController 的身份检查器的图片:

【问题讨论】:

    标签: ios objective-c xcode uiviewcontroller


    【解决方案1】:

    您的 hackscreen 类是 UIView 的子类,而不是 UIViewController 的子类。

    【讨论】:

      【解决方案2】:

      将 UIView 拖放到 xib,将她的类设置为您的类,然后转到 viewController 插座并在 viewController 的“视图”字段和放置的视图之间建立关系。

      【讨论】:

        【解决方案3】:

        请更改:

             @interface hackScreen : UIView
        

             @interface hackScreen : UIViewController
        

        【讨论】:

          【解决方案4】:

          您的 hackScreen 类必须是 UIViewController 的子类才能显示在检查器中。因此,您只需将 hackScreen 类更改为 UIViewController 的子类,而不是 UIView。

          例如

          @interface hackScreen : UIViewController

          ...

          @结束

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2012-09-23
            • 2010-10-04
            • 2018-08-22
            • 2019-06-16
            • 2010-12-17
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多