2012-03-01 64 views
0

我想要做的事:我可以在iPhone屏幕上同时使用两个视图吗?

我想让iPhone显示在上半部分,带有一些简单动画的Quartz绘制形状。在下半部分,我想使用UIKit按钮来绘制一些按钮。

基本上,上半部分的动画和形状对下半部分的按钮做出响应。

通过UISplitScreenViewController可以在iPad上执行此操作。但是,这只是iPad,在iPhone上使用它将导致异常错误。

在代码而言,这是我曾尝试:

//top frame 
CGRect topFrame = CGRectMake(0.0, 0.0, 320.0, 240.0); 
QuartzView *board = [[QuartzView alloc] initWithFrame:topFrame]; 
self.view = board; 


//bottom frame 
CGRect bottomFrame = CGRectMake(0.0, 240.0, 320.0, 240.0); 
//allocate the view 
self.view = [[UIView alloc] initWithFrame:bottomFrame]; 

什么这个结果是分配存在平局的后者,而前者被忽略并显示空白。两者都独立工作。

是否有一个替代实现可以实现这个结果逃脱了我?

回答

4

你的viewController将有一个视图属性。通常(在iPhone上)该视图填充整个屏幕。您可以将其他视图添加到该视图。

//top frame 
CGRect topFrame = CGRectMake(0.0, 0.0, 320.0, 240.0); 
QuartzView *board = [[QuartzView alloc] initWithFrame:topFrame]; 
[self.view addSubview:board]; 


//bottom frame 
CGRect bottomFrame = CGRectMake(0.0, 240.0, 320.0, 240.0); 
//allocate the view 
UIView *bottomView = [[UIView alloc] initWithFrame:bottomFrame]; 
[self.view addSubview: bottomView]; 
相关问题