2011-11-25 46 views
0

我最近通過點擊按鈕時彈出窗口中的tableview向用戶顯示項目列表。該表顯示了部分和標題。顯示UISplitviewController在PopOverViewController中

我現在正在嘗試不同的方式來顯示信息,我想嘗試在UISplitViewController中顯示數據。左視圖是帶標題的tableviewcontroller。右視圖也是一個帶有小標題的tableview控制器。

我仍然希望以popover的方式提供數據,但是當我嘗試過這種情況時,彈出窗口顯示沒有任何內容。我在SplitView的左右視圖的viewDidLoad方法中放置了斷點。休息時間正在受到打擊,但我的popover中沒有顯示任何內容。

如何在PopoverController中顯示UISplitView。

我的根查看

- (IBAction)showPopover:(id)sender { 

self.SVC = [[SplitViewContainerViewController alloc] init]; 

self.pickerPopover = [[[UIPopoverController alloc] initWithContentViewController:SVC] autorelease]; 


CGRect frame= CGRectMake(0,0, 0, 0); 
[self.pickerPopover presentPopoverFromRect:frame inView:self.view permittedArrowDirections:0 animated:NO]; 

的loadView中SplitViewContainerViewController

- (void)loadView 
{ 
    UIView *view=[[[UIView alloc]initWithFrame:CGRectMake(0, 0, 750, 880)]retain]; 
    self.view=view; 
    self.splitViewController = [[UISplitViewController alloc] init]; 
    self.leftViewController=[[[LeftViewController alloc] initWithStyle:UITableViewStylePlain] autorelease]; 
    self.rightViewController=[[[RightViewController alloc] initWithStyle:UITableViewStylePlain] autorelease]; 

    self.splitViewController.viewControllers= [NSArray arrayWithObjects:self.leftViewController, self.rightViewController, nil]; 
    [self.view addSubview:self.splitViewController.view]; 
    self.contentSizeForViewInPopover = CGSizeMake(750,880); 

    [super loadView]; 

} 

回答

1

UISplitViewControllers不起作用,除非它們是窗口的根視圖控制器。爲了做這樣的事情,你將需要創建一個自定義的分割視圖控制器,並使用它來代替UISplitViewController。

Apple's documentation

分割視圖控制器必須始終爲您創建任何接口的根。換句話說,您必須始終將UISplitViewController對象的視圖安裝爲應用程序窗口的根視圖。然後,您的拆分視圖界面的窗格可能包含導航控制器,選項卡欄控制器或實現您的界面所需的任何其他類型的視圖控制器。

你可能想通過看MGSplitViewController開始,但是,要知道,有在iOS 4的以下包括無法正確地向前旋轉和看法出現和消失事件給子視圖控制器的一些限制。

相關問題