UITabbarController.xib
有UILabel
作爲SubView
。UILabel添加到xib的UITabbarController視圖被UITabbarController隱藏子視圖控制器
當我運行應用程序UILabel
不可見,因爲子視圖控制器隱藏UILabel
。
我希望UILabel
在所有ChildView
控制器中都可見。
當我調試viewDidLoad
和viewWillAppear
該標籤看起來nil
對象雖然我已經在TabBarController.h
文件IBOutlet
連接的代碼。
我有這樣的代碼在.h文件中這一
@interface TestTabBarController : UITabBarController <UITabBarControllerDelegate>
@end
and in .m file
@interface TestTabBarController()
@property (weak, nonatomic)IBOutlet UILabel *historylabel;
@end
@implementation TestTabBarController
-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
if(self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]){
}
return self;
}
-(void)setChildrenViewControllers
{
// Set the View Controllers.
FirstViewController *viewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
SecondViewController *viewcontroller2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
ThirdViewController *viewController3 = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];
FourthViewController *viewController4 = [[FourthViewController alloc] initWithNibName:@"FourthViewController" bundle:nil];
self.viewControllers = @[viewController,viewcontroller2,viewController3,viewController4];
self.delegate = self;
}
@end
我打電話的Tabbarcontroller類如下
TestTabBarController *testtabbar = [[TestTabBarController alloc] initWithNibName:@"TestTabBarController" bundle:nil];
[testtabbar setChildrenViewControllers];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:testtabbar];
[self.navigationController presentViewController:navController animated:YES completion:nil];