1度閉じてもう1度同じ画面に遷移するとクラッシュします
swift
1// 遷移元 2import UIKit 3 4class AbcViewController: UIViewController { 5 6 @IBOutlet weak var scrollView: UIScrollView! 7 // ScrollScreenの高さ 8 var scrollScreenHeight:CGFloat! 9 // ScrollScreenの幅 10 var scrollScreenWidth:CGFloat! 11 12 var screenSize:CGRect! 13 14 override func viewDidLoad() { 15 super.viewDidLoad() 16 17 screenSize = UIScreen.main.bounds 18 // ページスクロールとするためにページ幅を合わせる 19 scrollScreenWidth = screenSize.width 20 scrollScreenHeight = screenSize.height 21 22 setupFirebase() 23 } 24 25 func setupFirebase() { 26 27 // 自作セルをテーブルビューに登録する 28 let communityXib = UINib(nibName: "CommunityTableViewCell", bundle: Bundle(for: type(of: self))) 29 30 // 描画開始の x,y 位置 31 let px:CGFloat = 0.0 32 var py:CGFloat = 0.0 33 34 let communityView = communityXib.instantiate(withOwner: self, options: nil).first as! UIView 35 communityView.isUserInteractionEnabled = true 36 print("あああ") 37 let gesture = UITapGestureRecognizer(target: self, action: #selector(AbcViewController.btnClick(sender:forEvent:))) 38 39 communityView.addGestureRecognizer(gesture) 40 self.scrollView.addSubview(communityView) 41 42 // 描画開始設定 43 var viewFrame:CGRect = communityView.frame 44 viewFrame.size.width = self.scrollScreenWidth 45 viewFrame.size.height = self.scrollScreenHeight 46 viewFrame.origin = CGPoint(x: px, y: py) 47 communityView.frame = viewFrame 48 // 次の描画位置設定 49 py += (self.screenSize.height) 50 51 // スクロール範囲の設定 52 let nHeight:CGFloat = self.scrollScreenHeight * CGFloat(1) 53 self.scrollView.contentSize = CGSize(width: self.scrollScreenWidth, height: nHeight) 54 } 55 56 @objc func btnClick(sender:UITapGestureRecognizer, forEvent event: UIEvent) { 57 print("ムカつく") 58 performSegue(withIdentifier: "toTest", sender: nil) 59 } 60 61} 62
swift
1//遷移先 2import UIKit 3 4class DefViewController: UIViewController { 5 6 override func viewDidLoad() { 7 super.viewDidLoad() 8 } 9 10 @IBAction func closePage(_ sender: Any) { 11 self.dismiss(animated: true, completion: nil) 12 } 13} 14
コンソールに表示されるエラーすべてを質問に追加してください。
エラー内容が出ません
https://dev.classmethod.jp/smartphone/xcode-shortcut-selected-5/
ここの中央あたりにある「デバッグエリア」の右側がコンソールです
ここにエラーが出力されていないですか?
画像追加しました
lldbとでるだけです
コード追加しました
回答1件
あなたの回答
tips
プレビュー