Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/101.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.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 TableView和segues出现无法识别的选择器错误_Ios_Swift_Xcode - Fatal编程技术网

Ios TableView和segues出现无法识别的选择器错误

Ios TableView和segues出现无法识别的选择器错误,ios,swift,xcode,Ios,Swift,Xcode,我正在编写一个iOS应用程序,我遇到了一个问题。我有三节课。在第一个类中,我使用segue转到第二个视图,我需要将数据从第一个类传输到第二个类。这就是为什么我使用: @IBSegueAction func goToSearchBar(_ coder: NSCoder) -> UIViewController? { currentCountry = countries[index] return SearchBar(coder: coder, selectedRegion:

我正在编写一个iOS应用程序,我遇到了一个问题。我有三节课。在第一个类中,我使用segue转到第二个视图,我需要将数据从第一个类传输到第二个类。这就是为什么我使用:

 @IBSegueAction func goToSearchBar(_ coder: NSCoder) -> UIViewController? {
    currentCountry = countries[index]
    return SearchBar(coder: coder, selectedRegion: currentCountry)
}
我必须在下一节课中实现以下内容:

init?(coder: NSCoder, selectedRegion: String) {
      self.selectedRegion = selectedRegion
      super.init(coder: coder)
}

required init?(coder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}
然后,在第二个类中,我想使用TableView。因此,我将故事板中的TableView连接到该类,并为单元格创建了另一个类:

class MovieCell: UITableViewCell {

  @IBOutlet weak var myImage: UIImageView!


  init(style: UITableViewCell.CellStyle, reuseIdentifier: String) {
    super.init(style: style, reuseIdentifier: reuseIdentifier)
  }

  required init?(coder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
  }

  override func awakeFromNib() {
    super.awakeFromNib()
  }

  override func setSelected(_ selected: Bool, animated: Bool) {
    super.setSelected(selected, animated: animated)
  }
}

我接通了所有的插座。但是,当我尝试运行代码时,出现以下错误:

Fatal error: init(coder:) has not been implemented: file .../MovieCell.swift, line 19
为了纠正这个问题,我修改了必需的init?功能与:

required init?(coder: NSCoder) {
    super.init(coder: coder)
}
但是我得到了一个错误:

 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-
      [UIImageView _isSymbolImage]: unrecognized selector sent to instance 0x7f7fcf823300'
 terminating with uncaught exception of type NSException
 CoreSimulator 732.18.6 - Device: iPhone 12 (58C5441D-67DD-4DF1-B603-B491641C816A) -
 Runtime: iOS 14.4 (18D46) - DeviceType: iPhone 12

我已确保连接了所有插座,并且没有丢失连接。
我将非常感谢您的帮助。

尝试删除init func,并确保标识符相同

您可以从您的cell类中删除这两个
init
方法。只是继承自
UITableviewCell
“确保我连接了所有插座,并且没有丢失连接”我对此表示怀疑。如果你想把这个项目发布到GitHub,我会帮你看一看,但它几乎肯定是一个不正确的插座连接。