Reputation: 247
I have a login page a the beginning of my app. when user is granted I'll redirect it to another storyboard.
In this below photo1: the white screen check is user granted or not. if yes I'll redirect the to Photo2. else I'll redirect them to the login page ( red pages in photo1).)
In below Photo2:(I'll show a table view which contains some data. when the user clicks one of them, it goes to the next page (right one).)
And Photo3 is just to clarify Photo2.
The problem is Photo2 after a user clicked a row in the table view. the back button does not work (it is visible in the app)
The code below shows the white screen's code in Photo1:
if let token = UserDefaults.standard.string(forKey: ConstantsKey.token){
if !token.isEmpty{
let storyboard : UIStoryboard = UIStoryboard(name: "MainTabBar", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "MainTabBarVC")
let rootController = UINavigationController(rootViewController: vc)
rootController.navigationBar.barTintColor = UIColor.init(red: 229/255, green: 28/255, blue: 60/255, alpha: 1)
self.present(rootController, animated: true, completion: nil)
}else{
// let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "LoginVc")
self.present(vc, animated: true, completion: nil)
}
}else{
let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "LoginVc")
self.present(vc, animated: true, completion: nil)
}
The code below shows the login page after the user is granted:
let storyboard : UIStoryboard = UIStoryboard(name: "MainTabBar", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "MainTabBarVC")
let rootController = UINavigationController(rootViewController: vc)
self.present(rootController, animated: true, completion: nil)
The code below shows the way I redirect the user to the page which has the problem in the photo 2:
let next = self.storyboard?.instantiateViewController(withIdentifier: "ShopVc") as! ShopViewController
self.navigationController?.pushViewController(next, animated: true)
I Also have added the code below to Delegate :
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .any, barMetrics: .default)
UINavigationBar.appearance().shadowImage = UIImage()
Am I doing something wrong here which might cause this problem?
//////////////////////////////////////////////////////////////// ANSEWER I created a new project which works fine there! I think it was the xCode's problem!
Upvotes: 0
Views: 961