![](/img/trans.png)
[英]popToViewController with a specific UITabBarController Tab/View
[英]UITabBarController set action to specific tab
我想對UITabBarController
上的特定tab
設置操作。 我怎樣才能做到這一點? 請參閱下面的代碼: 用代碼更新
@interface AccountTabViewController : UIViewController <UITabBarControllerDelegate, UITabBarDelegate>
{
IBOutlet UITabBarController *tabController;
IBOutlet UITabBar *tabBar;
}
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
if(tabBarController.selectedIndex == 0)
{
[self dismissModalViewControllerAnimated:YES];
}
}
它永遠不會進入方法! 請幫忙。
請參見UITabBarDelegate參考和UITabBarControllerDelegate協議參考 。
您正在尋找的方法是
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
}
或以下之一:
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
}
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
}
另外, UITabBarController參考 。
看一下UITabBarControllerDelegate方法:
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
if (tabBarController.selectedIndex == 0)
{
// First Tab is selected do something
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.