Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/107.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 类UITableViewCell不';没有名为storyboard的成员_Ios_Xcode_Uitableview_Swift - Fatal编程技术网

Ios 类UITableViewCell不';没有名为storyboard的成员

Ios 类UITableViewCell不';没有名为storyboard的成员,ios,xcode,uitableview,swift,Ios,Xcode,Uitableview,Swift,我知道这是导入类的问题,但我不确定需要哪个类 目前我有public类post,标题为leandimagetableviewcell:UITableViewCell,UINavigationControllerDelegate{ 我的问题出现在这里: 要解决我的问题,我需要导入哪些类?UITableViewCell既没有storyboard属性,也没有navigationController属性。UIViewController具有这两个属性。它们不可互换,它们是不同的类型。如果要访问单元格ta

我知道这是导入类的问题,但我不确定需要哪个类

目前我有
public类post,标题为leandimagetableviewcell:UITableViewCell,UINavigationControllerDelegate{
我的问题出现在这里:
要解决我的问题,我需要导入哪些类?

UITableViewCell既没有storyboard属性,也没有navigationController属性。UIViewController具有这两个属性。它们不可互换,它们是不同的类型。如果要访问单元格tableViewController的属性,则需要存储对视图控件的引用在你的牢房里,或者找到另一种方法


从表视图引用视图控制器 在表视图控制器中:

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithReuseIdentifier("CellIdentifier", indexPath: indexPath)
    cell.viewController = self
    return cell
}
var viewController: UIViewController?

override func prepareForReuse() {
    super.prepareForReuse()
    viewController = nil
}
在“表视图”单元格中,添加一个属性以容纳视图控制器:

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithReuseIdentifier("CellIdentifier", indexPath: indexPath)
    cell.viewController = self
    return cell
}
var viewController: UIViewController?

override func prepareForReuse() {
    super.prepareForReuse()
    viewController = nil
}

这是一种不同寻常的应用程序设计-通常推送发生在保存
UITableViewController
UITableViewCell
中。我希望将信息传递给下一个视图控制器(您的
DetailedViewController
)要在
prepareforsgue:sender:
中设置。即使您不使用segues,我仍然希望推送来自
UITableViewController
。此问题()Swift中有使用
prepareforsgue:sender:
tableView:didSelectRowAtIndexPath:
将新控制器推送到堆栈上并在新视图控制器中设置变量的答案。这基本上就是您试图做的。@Robotic Cat我知道这是不寻常的,但有必要的,因为我需要验证点击的位置我应该如何存储对视图控制器的引用,以便可以像我的代码所演示的那样使用值调用它