在iPad分割视图中的多个主视图和详细视图,uisplitview

时间:2011-03-08 16:35:21

标签: iphone ipad uisplitviewcontroller uibarbuttonitem uitoolbar

提前谢谢。我目前正在开发一个应用程序的iPad版本,它在iphone上有3个选项卡,每个选项卡加载3个不同的RSS源,然后在iPhone上使用导航控制器深入查看详细信息。在iPad上,有意义的是我在第一个splitview中加入了2个feed,然后为第3个feed添加了一个单独的master和detail。

实现这一目标的最佳做法是什么。我目前在第一个detailview中设置了一个工具栏按钮,它调用了appdelegate,它可以切换主和详细信息

- (void)switchViews {

    VideoSelectorViewController *masterViewController = nil;
    VideoDetailiPadViewController *detailViewController = nil;
    UIViewController *tempDetail = [self.splitViewController.viewControllers objectAtIndex:1];
    UIViewController *tempMaster = [self.splitViewController.viewControllers objectAtIndex:0];
    [tempDetail.view removeFromSuperview];
    [tempMaster.view removeFromSuperview];
    [tempDetail release];
    [tempMaster release];
    tempDetail = nil;
    tempMaster = nil;

  //  if (row == 1) {
        VideoSelectorViewController *newMasterViewController = [[VideoSelectorViewController alloc] initWithNibName:@"VideoSelectorViewController" bundle:nil];
        masterViewController = newMasterViewController;

        VideoDetailiPadViewController *newDetailViewController = [[VideoDetailiPadViewController alloc] initWithNibName:@"VideoDetailiPadViewController" bundle:nil];
        detailViewController = newDetailViewController;

  //  }

    // Update the split view controller's view controllers array.
    NSArray *viewControllers = [[NSArray alloc] initWithObjects:masterViewController, detailViewController, nil];
    self.splitViewController.viewControllers = viewControllers;
    [viewControllers release];

/*  // Dismiss the popover if it's present.
    if (popoverController != nil) {
        [popoverController dismissPopoverAnimated:YES];
    }*/

    // Configure the new view controller's popover button (after the view has been displayed and its toolbar/navigation bar has been created).
   // if (detailViewController.popover != nil) {
        [detailViewController showRootPopoverButtonItem:detailViewController.rootPopoverButtonItem];
    //}

    [masterViewController release];
    [detailViewController release];


}

当iPad处于横向状态时可以正常工作但是在纵向上按钮没有显示在工具栏中,我怎么能以编程方式调用 - (void)splitViewController:(UISplitViewController *)svc willHideViewController?我的方法的内存管理,我应该发布并设置为nil以前的主和详细信息,因为我在switchViews方法中使用那些临时对象?

另一种方法是将新主控推送到旧主控,只需替换详细信息即可。这更好,记忆力,性能等等再次感谢

2 个答案:

答案 0 :(得分:0)

由于没有人能够提供任何见解,我所做的是在detailview中创建第二个视图,该视图仅用于我的第二个tableview

答案 1 :(得分:0)

您的ViewController需要UISplitViewControllerDelegate

然后它会被自动调用

请参阅http://developer.apple.com/library/ios/#documentation/uikit/reference/UISplitViewControllerDelegate_protocol/Reference/Reference.html