Swift - 插座无法连接到重复的内容 [英] Swift - Outlets cannot be connected to repeating content

查看:27
本文介绍了Swift - 插座无法连接到重复的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

完整的错误是:从 TableViewController 到 AVPlayerView 的 playerView 插座无效.插座不能连接到重复的内容.

The full error is: The playerView outlet from the TableViewController to the AVPlayerView is invalid. Outlets cannot be connected to repeating content.

这个 之类的类似答案没有奏效(假设我尝试正确,我对 iOS 很陌生).

Similar answers like this one have not worked (assuming I am attempting them correctly, I'm very new to iOS).

我想要的是 TableViewCell 中的一个视图.

All I want is a view within a TableViewCell.

我尝试将 Storyboard 中的一个视图拖到我的 TableViewCell 的 contentView(和单元格)中,为其分配一个 AVPlayerView 类:UIView(以及 tableViewCell 的一个子类:AVPlayerView:UITableViewCell),然后从该视图中按住 ctrl+拖动在故事板中进入我的 TableViewController.然后它不编译.真的很困惑,谢谢帮助.

I've tried dragging a View in Storyboard to the contentView (and cell) of my TableViewCell, assigning it a class of AVPlayerView: UIView (and a subclass of tableViewCell: AVPlayerView: UITableViewCell), then ctrl+dragging from that view in the storyboard into my TableViewController. Then it doesn't compile. Really confused, thanks for the help.

推荐答案

您的表格视图可以包含静态内容或动态内容.

Your table view can have static content or dynamic content.

如果您希望表格视图始终具有相同的内容,请将其设置为静态(在界面构建器中),然后您可以在 UIViewController 中像这样链接出口.

If you want the table view to have always the same content, set it to static (in interface builder), and then you can link the outlets like that, in the UIViewController.

如果你想让表格视图单元格动态变化,你不能那样做.因为您可以重复单元格,而出口将是模棱两可的.您需要为您的单元格创建一个 UITableViewCell 子类,并在那里创建出口.

If you want the table view cells to change dynamically, you cannot do it that way. Because you could repeat cells and the outlet would be ambiguous. You need to create a UITableViewCell subclass for your cells, and create the outlets there.

澄清:在动态表格模式下,您需要按住ctrl+拖动插座到UITableViewCell子类,而不是视图控制器.

To clarify: in dynamic table mode, you need to ctrl+drag the outlet into the UITableViewCell subclass, not the view controller.

这篇关于Swift - 插座无法连接到重复的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆