开发者

iPhone - one level up in a TabBar and call a method

开发者 https://www.devze.com 2022-12-16 03:21 出处:网络
I have a NavBar, a TabBar and a SearchBar with a ScopeBar. So the user can perform a search via a remote server. Clicking on one TableRow of the TableView a new ViewController with a xib is pushed int

I have a NavBar, a TabBar and a SearchBar with a ScopeBar. So the user can perform a search via a remote server. Clicking on one TableRow of the TableView a new ViewController with a xib is pushed into.

It is doing some calculations and it is possible, that I have to dismiss this View(Controller) and I should go back like I am clicking the "back" button in the NavBar.

How could I do this programmatically and call a method in this ViewController, because I have to trigger the search with the saved search开发者_运维知识库 term.

Does anyone know this?

Thanks a lot in advance & Best Regards.


- (UIViewController *)popViewControllerAnimated:(BOOL)animated

if you are

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated


Use delegation. Have the table view controller create your new view controller newViewController and set newViewController.delegate = self before pushing it onto the navigation stack.

Then in newViewController, just before you popViewControllerAnimated: call some method like [delegate doWhateverWhenNewViewControllerIsPopped: ...]. Ideally you declare a protocol called something like NewViewControllerDelegate and have the controller above implement it.

You can change the back button of NewViewController to something like "Done" or whatever by changing it's left navigation button. (See the properties of UIViewController.)

Hope that makes sense.


I solved the problem, take a look at the comments.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号