我有一個包含UITabBarController的應用程序。只有滿足條件時才應該輸入最後一個選項卡。目前,我正在使用功能viewDidAppear
檢查此情況。但是,是否也可以在標籤打開並顯示之前進行每次檢查?iOS TabBarController:在進入新標籤之前運行檢查
根據第一反應我加入這兩個文件:
MainTabBarController.h
#import <UIKit/UIKit.h>
@interface MainTabBarController : UITabBarController
@end
MainTabBarController.m
#import "MainTabBarController.h"
@interface MainTabBarController()
@end
@implementation MainTabBarController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
- (void)tabBarController:(UITabBarController *)theTabBarController didSelectViewController:(UIViewController *)viewController
{
NSUInteger indexOfTab = [theTabBarController.viewControllers indexOfObject:viewController];
if(indexOfTab == 2)
{
NSLog(@"Is it working?");
}
}
@end
如何更改所選標籤的色調顏色? – user1324887 2016-08-01 02:17:42