Carlo Di Domenico Carlo Di Domenico - 3 months ago 26
iOS Question

Update view on TabController swift

I've a tabbed app, I've a "Profile tab" that let me check my profile info ONLY if logged in.

If I'm not logged in, I call a method that show a new page that ask me if I want login (this page have a button that unwind to the first tab [that is not profile tab]).

I would that if i close this page with the button (so i'm going to the first tab), when i re-tap on the "Profile tab" it recall the method that open the login page.

I hope you understand the problem...

Thank you!!

PS. if it could help: I need a procedure that let me to call a method every time I open that tab


func newMethod(){
print("login: \(login)")

let userFetch = NSFetchRequest<NSFetchRequestResult>(entityName: "UserEntity")

let users = try moc.fetch(userFetch)
if(users.count > 0){
print("utente connesso")
login = 1
performSegue(withIdentifier: "area_utente_segue", sender: self)
print("dovrebbe andare di la ")
}catch {}

this is the method called in viewWillAppear. With the help of @Sotiris Kaniras now every time i press on the tab, the method works. The problem is that it doesn't perform segue "area_utente_segue"


To do that, you can override the viewWillAppear: method... That way, whenever your viewController is about to appear, it will automatically call viewWillAppear... Just like viewDidLoad...