54662


なぜか1度閉じてもう１度開くとクラッシュします。  
コンソールにエラーは出ません  
Thread 1: EXC_BAD_ACCESS (code=1, address=0x1)

exception break point 追加してますが表示されません

遷移元

[code]

    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)
        }
    }
    
[/code]

遷移先

[code]

    import UIKit
    
    class DefViewController: UIViewController {
    
        override func viewDidLoad() {
            super.viewDidLoad()
        }
    
        @IBAction func closePage(_ sender: Any) {
            self.dismiss(animated: true, completion: nil)
        }
    }
    
[/code]

[![Storyboard](https://i.stack.imgur.com/NYaDh.png)](https://i.stack.imgur.com/NYaDh.png)


CC BY-SA 4.0
2019-05-02T13:03:12.110
54658
2019-05-02T19:56:32.593
2019-05-02T19:19:05.180
34162
34162
question
swift xcode
dismissで閉じて再度ページ遷移するとクラッシュする


下記のコードに変更して、解決しました

[code]

    @objc func btnClick(_ sender:UITapGestureRecognizer) {
        print("ムカつく")
        performSegue(withIdentifier: "toTest", sender: nil)
    }
    
    let gesture = UITapGestureRecognizer(target: self, action: #selector(self.btnClick(_:)))
    
[/code]


CC BY-SA 4.0
2019-05-02T19:56:32.593
54662
2019-05-02T19:56:32.593
34162
54658
answer