0

I'm trying to drag connections from some UIButtons on my Storyboard to a subclass of UIButton (called AGPiece in my header file. I have two storyboards for iPhone and iPad.

I was able to drag the iPhone ones over and create new outlets (@property (strong, nonatomic) IBOutlet AGPiece *piece1;, but now I'm coming to want to link the iPad storyboard to those same lines of code, I can't drag onto those lines, it doesn't get the highlight and let me, it only allows me to create a new one above or below that line. Obviously if I'd created the iPad ones first, it would've created those and not the phone, the issue is dragging to an existing line of code, as opposed to dragging out and creating a new one. It seems that Xcode expects a UIButton, and doesn't know that my AGPiece inherits from UIButton.

Is there a way around this? It worked fine when I was linking to UIButton instances and had UIButton written in the header file, but now I'm coming to implement the custom class, it doesn't want anything to do with it.

4

2 回答 2

1

试试这个...您会注意到 .h/.m 文件的行号列中有一个 BULLET,旁边是具有 IBACTION 或 IBOUTLET 的属性和方法。在一个视图中使用界面构建器,在另一个视图中使用您的 .h/.m 文件;您可以单击该项目符号并将其拖动到要链接的按钮/属性。

此外 - 您需要确保您的 ViewController 具有正确的“类”类型(与您的子类的名称匹配)。

您还可以控制从按钮/视图拖动到界面构建器中的“控制器”(橙色方块)。

编辑 根据上面的评论:如果您将按钮子类化,您可能需要在界面生成器中将按钮的“类”设置为按钮子类类型。

于 2013-01-31T15:39:25.800 回答
0

你是如何创建 ipad 故事板的,我建议你使用这里解释的方法:Converting Storyboard from iPhone to iPad (在 finder 中复制 iphone 故事板文件,将目标运行时属性修改为 ipad 并重新启动 xcode)

当您像那里一样创建 ipad 故事板时,它还保留了 iphone 故事板的插座连接,非常方便为您节省了大量时间。

于 2013-01-31T15:44:58.873 回答