When I switch from one screen to another, I get a black screen, I can't figure out why
Controller:
class AddContactsController: UIViewController {
// MARK: - Constants
private enum Constants {
static let textField = "nameTextCell"
static let datePicker = "datePicker"
static let pickerView = "pickerView"
static let textViewNotes = "textViewNotes"
static let alertOk = "OK"
static let alertQuestion = "It seems you made a mistake"
static let navigationTitle = "Create"
}
// MARK: - AddPresenter
var presenter: AddListPresenter?
func instantiate() -> UIViewController {
let vc = AddContactsController()
let presenter = AddListPresenter()
vc.presenter = presenter
return vc
}
Presenter:
class AddListPresenter {
weak var view: AddListController?
private var contact: Contact
init(contact: Contact? = nil) {
self.contact = contact ?? .init(
name: "",
surname: "",
middleName: "",
phone: "",
email: "",
date: "",
sex: "",
notes: ""
)
}
private var saveHieght: CGFloat = 0
How can this be avoided. I don't want to transfer presenter declarations to viewDidLoad
When you create a view controller by invoking it's initializer directly( e.g
AddContactsController(), it's content view does not get created automatically like it would from a storyboad or a nibfile.If you are creating you UI in code you need to show us your
loadView()method. That's where you code to create your view hierarchy belongs.Unless you have implemented
loadView()you won't get any content view and will see a black screen exactly as you describe.You also need to show the code that calls your
instantiate()method and what you do with the view controller instance that's returned.