Different controller showing up when back from Settings
up vote
0
down vote
favorite
For the new user I have several onboarding screens (all of them are in the same OnboardViewController
). If user is successfully registered, I'd change the root controller of my app from OnboardViewController
to PreLoadViewController
:
let mcVC = PreLoadController()
appDelegateTemp.window?.rootViewController = mcVC
I'm using this controller to display progress of the content loading. After the content is loaded, I'm changing the root controller once again:
if let appDelegateTemp = UIApplication.shared.delegate as? AppDelegate {
let mcVC = MainViewController()
let navy = UINavigationController(rootViewController: mcVC)
appDelegateTemp.window?.rootViewController = navy
}
It works, but I have a very strange bug. When I'm trying to change settings (like, mic settings
or notifications settings
) from the app, I have to go to iPhone settings:
if let settingsUrl = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.open(settingsUrl)
}
But when I'm back I'm shown the OnboardViewController
again as if appDelegate doesn't remember that current root controller is mcVC
(or, rather, UINavigationController
with embed mcVC
).
So, why is that, and what is the right way to fix this?
ios swift
add a comment |
up vote
0
down vote
favorite
For the new user I have several onboarding screens (all of them are in the same OnboardViewController
). If user is successfully registered, I'd change the root controller of my app from OnboardViewController
to PreLoadViewController
:
let mcVC = PreLoadController()
appDelegateTemp.window?.rootViewController = mcVC
I'm using this controller to display progress of the content loading. After the content is loaded, I'm changing the root controller once again:
if let appDelegateTemp = UIApplication.shared.delegate as? AppDelegate {
let mcVC = MainViewController()
let navy = UINavigationController(rootViewController: mcVC)
appDelegateTemp.window?.rootViewController = navy
}
It works, but I have a very strange bug. When I'm trying to change settings (like, mic settings
or notifications settings
) from the app, I have to go to iPhone settings:
if let settingsUrl = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.open(settingsUrl)
}
But when I'm back I'm shown the OnboardViewController
again as if appDelegate doesn't remember that current root controller is mcVC
(or, rather, UINavigationController
with embed mcVC
).
So, why is that, and what is the right way to fix this?
ios swift
When you change settings on Device Settings app, app would be terminated in some cases(like changing privacy setting as show in stackoverflow.com/questions/12522574/…). So It seems the app relaunching again..
– Natarajan
Nov 7 at 14:42
use can try to store some value lets saycurrentViewController
inUserDefaults
and check inappDelegate
which controller to present
– Vlad
Nov 7 at 15:09
1
No, @Natarajan is right, it's just an inevitable crash after changing some settings, it just wasn't obvious to me from simulator.
– lithium
Nov 7 at 15:13
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
For the new user I have several onboarding screens (all of them are in the same OnboardViewController
). If user is successfully registered, I'd change the root controller of my app from OnboardViewController
to PreLoadViewController
:
let mcVC = PreLoadController()
appDelegateTemp.window?.rootViewController = mcVC
I'm using this controller to display progress of the content loading. After the content is loaded, I'm changing the root controller once again:
if let appDelegateTemp = UIApplication.shared.delegate as? AppDelegate {
let mcVC = MainViewController()
let navy = UINavigationController(rootViewController: mcVC)
appDelegateTemp.window?.rootViewController = navy
}
It works, but I have a very strange bug. When I'm trying to change settings (like, mic settings
or notifications settings
) from the app, I have to go to iPhone settings:
if let settingsUrl = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.open(settingsUrl)
}
But when I'm back I'm shown the OnboardViewController
again as if appDelegate doesn't remember that current root controller is mcVC
(or, rather, UINavigationController
with embed mcVC
).
So, why is that, and what is the right way to fix this?
ios swift
For the new user I have several onboarding screens (all of them are in the same OnboardViewController
). If user is successfully registered, I'd change the root controller of my app from OnboardViewController
to PreLoadViewController
:
let mcVC = PreLoadController()
appDelegateTemp.window?.rootViewController = mcVC
I'm using this controller to display progress of the content loading. After the content is loaded, I'm changing the root controller once again:
if let appDelegateTemp = UIApplication.shared.delegate as? AppDelegate {
let mcVC = MainViewController()
let navy = UINavigationController(rootViewController: mcVC)
appDelegateTemp.window?.rootViewController = navy
}
It works, but I have a very strange bug. When I'm trying to change settings (like, mic settings
or notifications settings
) from the app, I have to go to iPhone settings:
if let settingsUrl = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.open(settingsUrl)
}
But when I'm back I'm shown the OnboardViewController
again as if appDelegate doesn't remember that current root controller is mcVC
(or, rather, UINavigationController
with embed mcVC
).
So, why is that, and what is the right way to fix this?
ios swift
ios swift
asked Nov 7 at 14:38
lithium
620617
620617
When you change settings on Device Settings app, app would be terminated in some cases(like changing privacy setting as show in stackoverflow.com/questions/12522574/…). So It seems the app relaunching again..
– Natarajan
Nov 7 at 14:42
use can try to store some value lets saycurrentViewController
inUserDefaults
and check inappDelegate
which controller to present
– Vlad
Nov 7 at 15:09
1
No, @Natarajan is right, it's just an inevitable crash after changing some settings, it just wasn't obvious to me from simulator.
– lithium
Nov 7 at 15:13
add a comment |
When you change settings on Device Settings app, app would be terminated in some cases(like changing privacy setting as show in stackoverflow.com/questions/12522574/…). So It seems the app relaunching again..
– Natarajan
Nov 7 at 14:42
use can try to store some value lets saycurrentViewController
inUserDefaults
and check inappDelegate
which controller to present
– Vlad
Nov 7 at 15:09
1
No, @Natarajan is right, it's just an inevitable crash after changing some settings, it just wasn't obvious to me from simulator.
– lithium
Nov 7 at 15:13
When you change settings on Device Settings app, app would be terminated in some cases(like changing privacy setting as show in stackoverflow.com/questions/12522574/…). So It seems the app relaunching again..
– Natarajan
Nov 7 at 14:42
When you change settings on Device Settings app, app would be terminated in some cases(like changing privacy setting as show in stackoverflow.com/questions/12522574/…). So It seems the app relaunching again..
– Natarajan
Nov 7 at 14:42
use can try to store some value lets say
currentViewController
in UserDefaults
and check in appDelegate
which controller to present– Vlad
Nov 7 at 15:09
use can try to store some value lets say
currentViewController
in UserDefaults
and check in appDelegate
which controller to present– Vlad
Nov 7 at 15:09
1
1
No, @Natarajan is right, it's just an inevitable crash after changing some settings, it just wasn't obvious to me from simulator.
– lithium
Nov 7 at 15:13
No, @Natarajan is right, it's just an inevitable crash after changing some settings, it just wasn't obvious to me from simulator.
– lithium
Nov 7 at 15:13
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53191650%2fdifferent-controller-showing-up-when-back-from-settings%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
When you change settings on Device Settings app, app would be terminated in some cases(like changing privacy setting as show in stackoverflow.com/questions/12522574/…). So It seems the app relaunching again..
– Natarajan
Nov 7 at 14:42
use can try to store some value lets say
currentViewController
inUserDefaults
and check inappDelegate
which controller to present– Vlad
Nov 7 at 15:09
1
No, @Natarajan is right, it's just an inevitable crash after changing some settings, it just wasn't obvious to me from simulator.
– lithium
Nov 7 at 15:13