It turns out that what I want to do is that when I come from a 3d shortcut, forcing the UITabBarController
to choose an index, if I do this in the tab bar viewDidAppear()
the problem is that the viewDidAppear()
of my main UIViewController
Embedded is not called, if I click again on the tab bar item then already if it is called. With the rest of the drivers does not happen, I understand why it is not the one that is first in the list of items in the UITabBarController
.
Tab bar controller: (Here it comes)
override func viewDidAppear(_ animated: Bool) {
if goTasks {
self.selectedIndex = 0
} else if goTodo {
self.selectedIndex = 2
} else if goProjects {
self.selectedIndex = 3
} else if goSearch {
self.selectedIndex = 0
}
}
My first UIViewController
: (Not called this method)
override func viewDidAppear(_ animated: Bool) {
print("Entry")
}
Is the problem override
the methods? Any solution?
In your UITabBarController class viewDidAppear func , call it's super class, like this
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if goTasks {
self.selectedIndex = 0
} else if goTodo {
self.selectedIndex = 2
} else if goProjects {
self.selectedIndex = 3
} else if goSearch {
self.selectedIndex = 0
}
}
After that, your first viewcontroller will call this method.
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
print("Entry")
}
i think you have to call function from super:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated) // here what i ment
if goTasks {
self.selectedIndex = 0
} else if goTodo {
self.selectedIndex = 2
} else if goProjects {
self.selectedIndex = 3
} else if goSearch {
self.selectedIndex = 0
}
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if goTasks {
self.selectedIndex = 0
} else if goTodo {
self.selectedIndex = 2
} else if goProjects {
self.selectedIndex = 3
} else if goSearch {
self.selectedIndex = 0
}
}
You need to add super.viewDidAppear(animated), hope its word now
我在做什么错误,我在viewWillAppear
里面放置了super.viewDidAppear(true)
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.