簡體   English   中英

我可以在iPhone屏幕上同時使用兩個視圖嗎?

[英]Can I use Two Views Simultaneously on the iPhone Screen?

我想做的事:

我希望iPhone在Quartz上半部分顯示一些簡單動畫的形狀。 在下半部分,我想使用UIKit按鈕繪制一些按鈕。

基本上,上半部分的動畫和形狀響應下半部分的按鈕。

在iPad上可以通過UISplitScreenViewController進行此操作。 但是,這僅是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];

結果是分配的后者被繪制,而前者被忽略並顯示空白。 兩者彼此獨立工作。

有沒有其他替代方案可以實現我所沒有的結果?

您的viewController將具有view屬性。 通常(在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];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM