2013-07-23 89 views
2

我正在研究iPad應用程序(實際上是將iPhone應用程序轉換爲iPad應用程序)。由於我可以在一個「iPad屏幕」上放置兩個「Iphone屏幕」(就空間而言),我的iPad視圖佔用了原始視圖的50%(通過我的主控制器加載)。IOS - 將子控制器/視圖加載到視圖

(到目前爲止好)

現在,在iPad上查看剩餘的50%,我想包括另一個View(對此我有一個控制器和視圖,iphone大小)。我試圖添加一個「視圖」組件,但我如何加載另一個控制器?這甚至有可能嗎?

  1. MainViewController裝載MyView1.xib
  2. 我想加載,在 「視圖」 組件,MySecondaryController,裝載MyView2.xib

Schéma http://img835.imageshack.us/img835/7977/d8fs.png http://imageshack.us/photo/my-images/835/d8fs.png/

感謝

+0

查看控制器遏制。去谷歌上查詢。 –

+1

http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html –

回答

3

你可以像下面這樣做...在Mainviewcontroller函數中編寫代碼(for例如在一些按鈕TAP)

yoursecondviewcontroller *objDate = [[yoursecondviewcontroller alloc] initWithNibName:@"yoursecondviewcontroller" bundle:nil]; 
    objDate.delegate = self; 
UIPopoverController *datePopOver = [[UIPopoverController alloc] initWithContentViewController:objDate]; 
    datePopOver.delegate = self; 
    [datePopOver setPopoverContentSize:CGSizeMake(320,393)];//give any size you want. 
    [datePopOver presentPopoverFromRect:CGRectMake(50,700, 320, 393) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];//give size and origin whatever you want in FromRect ..... 

您還可以定義在.h文件中UIPopoverController對象....

,不要忘記設置UIPopoverController的委託,它是UIPopoverControllerDelegate

讓我知道它工作與否!

快樂編碼!

+0

其他答案也很好 - 但這一個正是我想要的。謝謝所有 – lbarman

+0

@LudovicBarman:非常感謝.... !!! !!! – NiravPatel

相關問題