我有一个UINavigationController,推上另一个UIViewController。在这个UIViewController中,我将在纵向模式下显示一个UITableView,在横向模式下显示另一个视图。UIViewController没有填充屏幕
因此,在我viewDidLoad我创建UIView,然后添加到这2个ViewControllers。我的问题是,当它加载时,我会在顶部获得以下白色边距。
我想这是因为(我在下面的步骤3)
CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
[[self view] setFrame:appFrame];
没有返回全屏的,减去的导航栏。这是正确的吗?如果是这样,我怎么能使它返回全尺寸,所以没有白边?
- (void)viewDidLoad
{
[super viewDidLoad];
// Step 1 - Set up the tableDataView for vertical layout
TableDataViewController *tableController = [[TableDataViewController alloc] init];
self.tableDataViewController = tableController;
[tableController release];
// Step 2 - Set up the graphView for horizontal layout
GraphViewController *graphController = [[GraphViewController alloc]
initWithNibName:@"GraphViewController" bundle:nil];
self.graphViewController = graphController;
[graphController release];
// Step 3 - Get the screen size
CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
[[self view] setFrame:appFrame];
// Step 4 - Add the vertical view to the containerView
// and then add the containerView to this controller
containerView = [[[UIView alloc] initWithFrame:appFrame] autorelease];
[[self view] addSubview:containerView];
[containerView addSubview:[tableDataViewController view]];
// Step 5 - Add to the active view so we can test for it later
activeView = [tableDataViewController view];
}
非常感谢
迈克
当我你有什么建议上面我得到以下几点:Screenbounds {{0,0},{ 320,480}},Screenframe {{0,20},{320,460}}。所以理想情况下,我需要使用[[UIScreen mainScreen]边界]来获得最大尺寸。但是,我这样做,导航栏下方仍有一个白色边距。这就像是完全无视它。麦克风。 – hydev 2011-02-10 21:53:44