Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.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/19.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 Swift和iPhone 5中的EXC_错误访问内核无效地址_Ios_Swift_Swift3_Crash_Crashlytics - Fatal编程技术网

Ios Swift和iPhone 5中的EXC_错误访问内核无效地址

Ios Swift和iPhone 5中的EXC_错误访问内核无效地址,ios,swift,swift3,crash,crashlytics,Ios,Swift,Swift3,Crash,Crashlytics,我刚刚发布了这个应用程序,我对iPhone5、5c和iOS 10.3.3(仅限)有一个问题 我真的不明白这个问题,即使是Crashlytics报告: 问题似乎来自这一行: @objc UserProfilViewController.collectionView(UICollectionView, layout : UICollectionViewLayout, sizeForItemAtIndexPath : IndexPath) -> CGSize 这是我的代码: // Cell

我刚刚发布了这个应用程序,我对iPhone5、5c和iOS 10.3.3(仅限)有一个问题

我真的不明白这个问题,即使是Crashlytics报告:

问题似乎来自这一行:

@objc UserProfilViewController.collectionView(UICollectionView, layout : UICollectionViewLayout, sizeForItemAtIndexPath : IndexPath) -> CGSize
这是我的代码:

// Cell size
   func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize {

      let size: CGSize
      if cellIsNull == false {
         size = CGSize(width: self.view.frame.size.width * 0.47, height: self.view.frame.size.width * 0.47)
      } else {
         size = CGSize(width: self.view.frame.size.width, height: self.view.frame.size.width * 0.47)
      }
      return size
   }

如果我在模拟器上运行该应用程序(使用iPhone 5),则该应用程序不会崩溃,而且我没有iPhone 5,因此我不会对其进行测试。

称之为巧合。几个小时前我问了一个问题。不一样但相似。
解决方案是将
@objc
放在函数定义前面。所以函数应该是这样的:

@objc func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize { 
....  

} 

需要注意的主要问题是,碰撞是随机的。我自己还没有收到这个。这可能取决于iOS或间接的Swift版本。

你知道@objc为什么工作吗?我面临着类似的崩溃,无法复制。谢谢。你能解释一下为什么在函数中添加
@objc