我的视图控制器有一些框架问题

时间:2014-07-21 08:30:51

标签: ios objective-c uitableview uiviewcontroller

在我的iOS应用代码中。我已使用tabbarviewcontroller设置windows.rootviewcontroller,如下所示:


navigaitonController = [[UINavigationController alloc] initWithRootViewController:tabBarViewController];

[navigaitonController.navigationBar setBarTintColor:[UIColor colorWithHexString:@"15a4fa"]];
[self.window setRootViewController:navigaitonController];

我有五个viewcontrollers这样:


PhotoViewController *photoViewController = [[PhotoViewController alloc] initWithNibName:@"PhotoViewController" bundle:nil];
PhotoAlbumViewController *photoAlbumViewController = [[PhotoAlbumViewController alloc] initWithNibName:@"PhotoAlbumViewController" bundle:nil];
videoViewController = [[VideoViewController alloc] init];
MusicViewController *musicViewController = [[MusicViewController alloc] init];
documentViewController = [[DocumentViewController alloc] init];

UINavigationController *albumNavigation = [[UINavigationController alloc] initWithRootViewController:photoAlbumViewController];
UINavigationController *photoNavigation = [[UINavigationController alloc] initWithRootViewController:photoViewController];
UINavigationController *musicNavigation = [[UINavigationController alloc] initWithRootViewController:musicViewController];
[albumNavigation.navigationBar setBarTintColor:[UIColor colorWithHexString:@"15a4fa"]];
[photoNavigation.navigationBar setBarTintColor:[UIColor colorWithHexString:@"15a4fa"]];
[tabBarViewController setViewControllers:@[photoNavigation, albumNavigation, musicNavigation, videoViewController, documentViewController]];

tabBarViewController = [[YDRootViewController alloc] init];
NSMutableArray *viewControllers = [[NSMutableArray alloc] init];
[viewControllers addObject:photoNavigation];
[viewControllers addObject:albumNavigation];
[viewControllers addObject:musicNavigation];
[viewControllers addObject:videoViewController];
[viewControllers addObject:documentViewController];
[tabBarViewController setViewControllers:viewControllers];

VideoViewController我有tableview这样:


CGRect tableViewFrame = self.view.frame;
tableViewFrame.origin.y = 64;
tableViewFrame.size.height = tableViewFrame.size.height - 49;
videoTableView = [[UITableView alloc] initWithFrame:tableViewFrame];
[videoTableView setDelegate:self];
[videoTableView setDataSource:self];
[self.view addSubview:videoTableView];

然后我运行这个,但在我的手机中,它的框架是正确的,但在我播放视频后使用MPMoviplayViewControllertableView's框架错误,如CGRectMake(0, 128, 320, 391)

我该如何解决这个问题。请告诉我 。谢谢你的帮助。

1 个答案:

答案 0 :(得分:0)

UITabBarController中不需要UINavigationController,只需设置如下代码:

[self.window setRootViewController: tabbarviewcontroller];