なぜか1度閉じてもう1度開くとクラッシュします。
コンソールにエラーは出ません
Thread 1: EXC_BAD_ACCESS (code=1, address=0x1)
exception break point 追加してますが表示されません
遷移元
import UIKit
class AbcViewController: UIViewController {
@IBOutlet weak var scrollView: UIScrollView!
// ScrollScreenの高さ
var scrollScreenHeight:CGFloat!
// ScrollScreenの幅
var scrollScreenWidth:CGFloat!
var screenSize:CGRect!
override func viewDidLoad() {
super.viewDidLoad()
screenSize = UIScreen.main.bounds
// ページスクロールとするためにページ幅を合わせる
scrollScreenWidth = screenSize.width
scrollScreenHeight = screenSize.height
setupFirebase()
}
func setupFirebase() {
// 自作セルをテーブルビューに登録する
let communityXib = UINib(nibName: "CommunityTableViewCell", bundle: Bundle(for: type(of: self)))
// 描画開始の x,y 位置
let px:CGFloat = 0.0
var py:CGFloat = 0.0
let communityView = communityXib.instantiate(withOwner: self, options: nil).first as! UIView
communityView.isUserInteractionEnabled = true
print("あああ")
let gesture = UITapGestureRecognizer(target: self, action: #selector(AbcViewController.btnClick(sender:forEvent:)))
communityView.addGestureRecognizer(gesture)
self.scrollView.addSubview(communityView)
// 描画開始設定
var viewFrame:CGRect = communityView.frame
viewFrame.size.width = self.scrollScreenWidth
viewFrame.size.height = self.scrollScreenHeight
viewFrame.origin = CGPoint(x: px, y: py)
communityView.frame = viewFrame
// 次の描画位置設定
py += (self.screenSize.height)
// スクロール範囲の設定
let nHeight:CGFloat = self.scrollScreenHeight * CGFloat(1)
self.scrollView.contentSize = CGSize(width: self.scrollScreenWidth, height: nHeight)
}
@objc func btnClick(sender:UITapGestureRecognizer, forEvent event: UIEvent) {
print("ムカつく")
performSegue(withIdentifier: "toTest", sender: nil)
}
}
遷移先
import UIKit
class DefViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func closePage(_ sender: Any) {
self.dismiss(animated: true, completion: nil)
}
}