![](/img/trans.png)
[英]Refresh a UITabBar tab's view or call a method from the UITabBar tab's view when the tab is reselected
[英]Call a method when switchig views with UITabBar
使用UITabBarController切換視圖時,有什么方法可以自動調用自定義方法? 就像,我希望他能夠在UILabel的一個視圖中設置NSString時,使用相同的字符串自動更新不同選項卡上的不同標簽。 謝謝!
是的,看看UITabBarControllerDelegate協議 。 您要做的就是將對象注冊為標簽欄委托,並實現shouldSelect
或didSelect
回調( didSelect
會是更好的選擇)。 每次標簽欄切換時,都會調用該回調。
看看UITabBarControllerDelegate
中的tabBarController:didSelectViewController:
在您的委托中實現該方法,並在那里進行所需的任何更新。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.