Answer the question
In order to leave comments, you need to log in
How to activate the transition to Swift?
People, tell me please.
I need to make a check during the opening of the view and perform the transition.
Now I'm doing it like this
if (login != "" && pass != ""){
//Проводим авторизацию
if auth(login: "", pass: "")==true {
print("Auth true")
if let personalCabinet = self.storyboard?.instantiateViewController(withIdentifier: "ShowPersonalCabinetDetailAction") as? PersonalCabinetInfoView {
personalCabinet.modalTransitionStyle = .crossDissolve
personalCabinet.modalPresentationStyle = .overCurrentContext
self.present(personalCabinet, animated: true, completion: nil)
}
}else{
print("Авторизация не удалась")
}
}else{
print("Авторизационные даты не заполнены")
}
Answer the question
In order to leave comments, you need to log in
You can do it without Segway, for example, like this:
I don’t know what the class attached to the target view controller is called, but I assumed that the name is ShowPersonalCabinetDetailAction. If anything, put it like you have.
if (login != "" && pass != ""){
//Проводим авторизацию
if auth(login: "", pass: "")==true {
print("Auth true")
// Вывод контроллера
if let personalCabinet = self.storyboard?.instantiateViewController(withIdentifier: "ShowPersonalCabinetDetailAction") as? ShowPersonalCabinetDetailAction { // после as? это название класса вашего контроллера, куда переходите, точно не знаю какое, предположил, что такое же как и идентификатор
personalCabinet.modalTransitionStyle = .crossDissolve // тут можно поменять на другие типы анимации появления контроллера
personalCabinet.modalPresentationStyle = .overCurrentContext
self.present(personalCabinet, animated: true, completion: nil)
}
}else{
print("Авторизация не удалась")
}
}else{
print("Авторизационные даты не заполнены")
}
This won't work in viewDidLoad because the view is not actually attached to the window yet. You can try moving it to viewDidAppear. But the code, of course, is not ice, 2 if else instead of guard, not to mention what is written in separate functions, but here they are only called. And there is another scary word patterns :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question