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?










share|improve this question






















  • 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








  • 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















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?










share|improve this question






















  • 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








  • 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













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?










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 say currentViewController in UserDefaults and check in appDelegate 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










  • 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




    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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini