Pergunta

I have tabview based project. how can I make a view connected to a tab perform a certain method every time the tab is selected?

Please help, Thanks

Foi útil?

Solução

Assuming the tab var is the main way to make the view appear, you can hook code into:

- (void)viewDidAppear:(BOOL)animated

or ...

- (void)viewWillAppear:(BOOL)animated

Outras dicas

EDIT: I mistook TabBar for TableView. I'm sorry for that. I let my old answer being here, it might help you in another problem.

The answer that bryamac gave you is the right one.

When you click the tab then you probably load some UIView to display some content. For that UIView you must have a controller class. In that controller class there are - (void)viewDidAppear:(BOOL)animated and - (void)viewWillAppear:(BOOL)animated methods which you may use.

Old answer

What you want to do is make a class to a UITableViewDelegate.

Then you must set this class as the delegate of the UITableView, you can to that in the Interface Builder by right-clicking on the UITableView and dragging its delegate to the class that you have chosen, e.g. its own controller class.

Then you implement this method inside the UITableViewDelegate-class:

– tableView:didSelectRowAtIndexPath;

More information here.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top