简体   繁体   English

如何按下选定的选项卡栏项来重新加载我的视图

[英]How to make pressing a selected tab bar item reload my view

I have a view contained in a tabbarcontroller. 我在tabbarcontroller中包含一个视图。 When a user clicks on one of the items I load data into that view. 当用户单击其中一项时,我将数据加载到该视图中。 However, if they click that item again I want to reload the view again. 但是,如果他们再次单击该项目,我想再次重新加载视图。

So far I am running the didSelectViewController method in my tabbarcontroller and from there I popToRootViewControllerAnimated. 到目前为止,我正在我的tabbarcontroller中运行didSelectViewController方法,然后从此处运行popToRootViewControllerAnimated。 However it appears that popToRootViewControllerAnimated doesn't execute the viewdidload, viewwillload, or viewwillappear methods, so I am stuck as to how to reload... 但是似乎popToRootViewControllerAnimated没有执行viewdidload,viewwillload或viewwillappear方法,所以我对如何重新加载感到困惑...

While it may not be UI friendly to refresh an already selected tabbar item (user already selected that item and it shows it as selected. They would then expect to pull down to refresh), have you tried adding [viewController.view setNeedsDisplay]; 虽然刷新一个已选择的选项卡项可能不适合UI使用(用户已经选择了该选项卡项,并且该项目显示为选中状态。然后他们希望下拉以刷新),但是否尝试添加[viewController.view setNeedsDisplay]; in your didSelectViewController ? didSelectViewController

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM