每次单击选项卡栏项目时如何刷新视图?
我正在使用 TabBar 制作一个应用程序。但 TabBarController 不是 RootViewController。选项卡栏中有 4 个选项卡。这些选项卡之一是历史记录,它与显示历史记录的表格视图链接。我想每次单击该视图时都刷新该视图,以便可以获得更新的表格视图。我怎样才能做到这一点?提前致谢。
I am making an application with TabBar. But TabBarController is not RootViewController. In the Tab Bar there are 4 tabs. One of those tabs is history which is linked with a table view which shows history. I want to refresh that view every time when i click that so that i can get updated tableview. How can i do that? Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我已经做到了这一点。在这种情况下,每当用户在“历史记录”屏幕上单击选项卡时,我都会调用 Web 服务来获取历史记录并更新表格视图。
I have achieved this. In this case, whenever user tabs on History screen I call web service for history and update tableview.
而不是使用
(void)ViewDidLoad
使用viewWillAppear:(BOOL)animated
instead of using
(void)ViewDidLoad
useviewWillAppear:(BOOL)animated
使用
- (void) viewWillAppear:(BOOL)animated
更新视图中的任何内容。每次视图即将显示时都会调用此方法。
use
- (void) viewWillAppear:(BOOL)animated
to update any content in your view.This method will be called every time the view is about to be displayed.
下面的代码添加了 ^^
如果您更改 tabBarIndex,同时调用 -(void)viewWillAppear。
参考 Apple 示例代码:这是关于 UITabBarController 的精彩教程
http://developer.apple.com/library/ios/ #samplecode/TheElements/Introduction/Intro.html
Apple 示例代码未添加 [super viewWillAppear:animated];
below code added plz ^^
If you change a tabBarIndex, At the same time -(void)viewWillAppear called.
refer a Apple Sample Code: that is amazing great tutorial for you about UITabBarController
http://developer.apple.com/library/ios/#samplecode/TheElements/Introduction/Intro.html
Apple Sample Code is no added [super viewWillAppear:animated];