EPKgames EPKgames - 5 months ago 18
iOS Question

swift when I try to make an action with my tab bar item, I can only make an outlet or an outlet collection how can I make an action?

I am making an app with 4 tabbar items. one of them has a WebView and on the website there are buttons that go to other things on the website or to an other website but how can I make it that if I press the tab bar item again that it goes back to the first view (like the app store when you press the tab bar item again you go back to the beginning).
when I try to add a insert a action I can only choose between make an outlet or an outlet collection.

only outlet and outlet collection image

thanks for reading this, I hope I gave enough information to understand my quistion.

Answer

I found the answer!

first I ran the code in the viewdidload but the viewdidload only loads one time so if you want to run it every time you go to the tabbar you need to paste the same code inside the viewwillappear:

override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)
}

if you run your code in the viewWillAppear than it will load every time you go to the tabbar

I hope this helps the people that also have this question.