I need to create an application, so that when loading it does not require user registration, the user can work with the limited functions of the application. If the user is registered or registered, we need to show him more functionality.
Terms:
The application must have a TabBarController, NavigationController and TableViewControleer. Language: Swift, Xcode 6.4
How I tried to do this:
I used the storyboard to add controllers and segues.
There are two segments (type: "show (for example, push)") with the identifiers "registeredUser" and "notRegisteredUser". I wrote code that runs in the viewWillAppear method of the NavigationController class. It checks if the user is registered / registered each time the user clicks the "Settings" button. Depending on the result of this check, the user accesses a specific controller (green if it is registered / registered, yellow if not). I do not use the viewDidLoad method, because the user can click the "Exit" button at any time, and the application should immediately send it to a yellow screen.
class NavigationController:UINavigationController {
var userisregistred:Bool!
override func viewDidLoad() {
super.viewDidLoad()}
override func viewWillAppear(animated: Bool) {
userisregistred = UserAccauntUtil.userRegistrationCheck()
if (userisregistred == false ) {
self.performSegueWithIdentifier("notRegisteredUser", sender: self)
}
else if(userisregistred == true ){
self.performSegueWithIdentifier("registeredUser", sender: self)
}
}
}
Problem:
"" , ( ), "" "" , viewWillAppear , , "" /, NavBar. .
, : TabBarController, NavigationController.
, . .
/ :
"", NotRegistedUser.swift
class RegisteredUser: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.setHidesBackButton(true, animated:false);
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
, .