[英]Outlets found nil after moving tableviewcell to new view controller
I originally had several UITableViewCell
s on a UIViewController
with a UITableView
.我最初在
UIViewController
和UITableView
上有几个UITableViewCell
。 Then, I moved the UITableViewCell
s to a new UITableViewController
I created because I wanted to make them static cells and the only way to make them static was to use them on a UITableViewController
.然后,我将
UITableViewCell
移动到我创建的新UITableViewController
中,因为我想让它们成为 static 单元,而使它们成为 static 的唯一方法是在UITableViewController
上使用它们。 However, after I moved, them, although everything was connected and all the cells were set to the right xib files, the app crashed and it said the outlets on the UITableViewCell
s, like my UILabel
s, were found nil.然而,在我搬家后,尽管一切都已连接并且所有单元格都设置为正确的 xib 文件,但应用程序崩溃了,它说
UITableViewCell
上的插座,就像我的UILabel
一样,被发现为零。 I then tried to create brand new UITableViewCell
s with brand new xib files on the UITableViewController
, but then I couldn't even connect any outlets for any UILabel
s or anything else.然后,我尝试在
UITableViewCell
上使用全新的 xib 文件创建全新的UITableViewController
,但后来我什至无法为任何UILabel
或其他任何东西连接任何插座。 Does anyone know how to troubleshoot this?有谁知道如何解决这个问题? All my code looks normal and I've been using
UITableView
s for a long time, just never creating static cells before.我所有的代码看起来都很正常,而且我已经使用
UITableView
很长时间了,只是之前从未创建过 static 单元。
I figured it out!我想到了! In a
UITableViewController
with Static Cells you don't need to create a custom class for the cells and drag your outlets there (what I did);在带有 Static 单元的
UITableViewController
中,您无需为单元创建自定义 class 并将您的插座拖到那里(我做了什么); you can just drag your outlets directly onto the UITableViewController
and it will work there.你可以直接将你的插座拖到
UITableViewController
上,它就会在那里工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.