2012-03-01 65 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]; 
相關問題