简体   繁体   English

为什么我不能从自定义UIView类拖动插座?

[英]Why I can't drag outlets from a custom UIView Class?

I have a TableViewController With a dynamic cell and a view I added above it. 我有一个带有dynamic cellTableViewController和一个在其上方添加的视图。 I've created a UIView class and added it as a custom class for that view ( just like I do with a custom cell ) but I can't drag labels etc from that UIView to its .h file . 我已经创建了一个UIView类并将其作为该视图的自定义类添加(就像我对custom cell所做的那样),但是我无法将标签等从该UIView拖到其.h file Only to the main TableViewController.h file. 仅到主TableViewController.h文件。 Any idea what's the problem? 知道有什么问题吗?

A table view in a UITableViewController takes up the whole screen, so the view you added is actually in the table view, not above it, so that's why you can connect to the table view controller. UITableViewController中的表视图占据了整个屏幕,因此您添加的视图实际上在表视图中,而不是在其上方,因此这就是您可以连接到表视图控制器的原因。 If you want to add a view above the table, use a UIViewController instead, and resize the table view so it doesn't take up the whole screen. 如果要在表格上方添加视图,请改用UIViewController并调整表格视图的大小,以免占据整个屏幕。

I've noticed this too (for an OS X project) in Interface Builder. 我在Interface Builder中也注意到了这一点(对于OS X项目)。 I'm not sure if it is a bug or not in IB. 我不确定这是否是IB中的错误。

What you will have to do is enter the @property declarations in your .h file manually and then you will be able to connect them. 您需要做的是在.h文件中手动输入@property声明,然后就可以连接它们。

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

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