我的UITabBarController的tabBar稍微偏离视图,请告诉我我的代码有什么问题:
LoggedInViewController *lvc = [[[LoggedInViewController alloc]
initWithAccount:account] autorelease];
[self presentModalViewController:lvc animated:YES];
- (void)viewDidLoad
{
self.tabController = [[UITabBarController alloc] init];
LoggedInFeedNavigationController *navController;
navController = [[LoggedInFeedNavigationController alloc]
initWithAccount:self.account];
[self.tabController setViewControllers:
[NSArray arrayWithObject:navController]];
[self.view addSubview:self.tabController.view];
[super viewDidLoad];
}
答案 0 :(得分:0)
您正在将tabController视图添加为子视图,但是您没有指定它应在父视图中的位置,或者在父视图更改大小时应如何调整它的大小。请尝试以下方法:
- (void)viewDidLoad
{
[super viewDidLoad]; // see note
self.tabController = [[UITabBarController alloc] init];
LoggedInFeedNavigationController *navController;
navController = [[LoggedInFeedNavigationController alloc]
initWithAccount:self.account];
[self.tabController setViewControllers:
[NSArray arrayWithObject:navController]];
UIView *tabView = self.tabController.view;
[self.view addSubview:tabView];
tabView.frame = self.view.bounds;
tabView.autoresizingMask = (UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight);
}
注意:您required不能[super viewDidLoad]
拨打viewDidLoad
,但如果您 决定拨打电话,则应在beginning处致电{{1}}方法,而不是最终方法。