xmartlabs / Eureka

Elegant iOS form builder in Swift
https://eurekacommunity.github.io
MIT License
11.78k stars 1.33k forks source link

Tapping inside an enabled text area row crashes #795

Closed cedared closed 7 years ago

cedared commented 7 years ago

I have the same problem with #763 and #718

but I really don't override viewwillappear

import UIKit
import Eureka

class NormalLoginViewController: FormViewController {
    var delegate: NormalLoginViewControllerDelegate?

}

extension NormalLoginViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        setupView()
        formCreater()
        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

extension NormalLoginViewController {
    fileprivate func setupView() {
        tableView?.backgroundColor = UIColor.dancebookBackground
        tableView?.isScrollEnabled = false
    }

    fileprivate func formCreater() {
        form +++ Section()
            <<< TextRow() {
            row in
            row.cell.textField.textAlignment = .left
            row.cell.textField.placeholder = "用户名/手机号"
        }
            <<< PasswordRow() {
                row in
                row.cell.textField.textAlignment = .left
                row.cell.textField.placeholder = "密码"
        }
    }
}

protocol NormalLoginViewControllerDelegate {

}
cedared commented 7 years ago

even I add viewwillappear it still crash

import UIKit
import Eureka

class NormalLoginViewController: FormViewController {
    var delegate: NormalLoginViewControllerDelegate?

}

extension NormalLoginViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        setupView()
        formCreater()
        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
    }

}

extension NormalLoginViewController {
    fileprivate func setupView() {
        tableView?.backgroundColor = UIColor.dancebookBackground
        tableView?.isScrollEnabled = false
    }

    fileprivate func formCreater() {
        form +++ Section()
            <<< TextRow() {
            row in
            row.cell.textField.textAlignment = .left
            row.cell.textField.placeholder = "用户名/手机号"
        }
            <<< PasswordRow() {
                row in
                row.cell.textField.textAlignment = .left
                row.cell.textField.placeholder = "密码"
        }
    }
}

protocol NormalLoginViewControllerDelegate {

}
lastmboy commented 7 years ago

I had to comment out most of the inputAccessoryView method in Core.swift. I commented out the navigationAccessoryView lines in the method. Not a permanent solution by any means, but it temporarily solved the problem. I believe there is a problem with the navigationAccessoryView not getting initiated properly in some cases. Check where you are crashing. If it's in this method, could be the same thing.

yannbu commented 7 years ago

Same Problem here. I override viewWillAppear and it still crashes

d-date commented 7 years ago

I resoloved this issue by adding below on viewDidLoad()

navigationAccessoryView = NavigationAccessoryView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: 40))

The reason why the crush is occuring is navigationAccessoryView, which is IUO property, is not initialized maybe.

mtnbarreto commented 7 years ago

I couldn't run into the same issue. Anyway after some testing I think we can move the code that initialise NavigationAccessoryView from viewWillAppear to viewDidLoad.