导航时UIPopoverController的问题

时间:2011-08-31 07:52:32

标签: iphone ipad

我有UIPopoverController和两个ViewController类。

SaveProject和ProjectName是viewController类。

当我点击保存项目时。它给我导航并加载另一个视图。

但是UIPopoverController的大小高度会增加到总视图大小。

任何人都可以帮我解决这个问题。

我在这里附上代码:

-(void)createSaveAndCloseView{

    saveAndCloseViewController = [[WGSaveAndCloseViewController alloc]init];
    [saveAndCloseViewController.view setFrame:CGRectMake(0, 0, 310, 171)];
    saveAndCloseViewController.navigationItem.title = @"Save or Discard";
    UIBarButtonItem *cancel = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStylePlain target:self action:@selector(cancelAction:)];          
    saveAndCloseViewController.navigationItem.rightBarButtonItem = cancel;
    [cancel release];
    UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController:saveAndCloseViewController];

    saveAndClosePopupView = [[UIPopoverController alloc] initWithContentViewController:navControl];
    saveAndClosePopupView.delegate = self;
    saveAndClosePopupView.popoverContentSize = CGSizeMake(312, 160);
    saveAndCloseViewController.view.contentMode = UIViewContentModeScaleAspectFill;
    [saveAndClosePopupView presentPopoverFromRect:[saveAndClose bounds] inView:saveAndClose permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

    [navControl release];

}

-(void)saveProjectClick:(id)sender{
        if (saveProject.tag == tagSave) {

        WGNameProjectViewController *nameProjectViewController = [[WGNameProjectViewController alloc] initWithNibName:nil  bundle:nil];
        [self.navigationController pushViewController:nameProjectViewController animated:YES];
        nameProjectViewController.navigationItem.title = @"Name Project";
        [nameProjectViewController release];
        nameProjectViewController = nil;

    }
}

enter image description here

1 个答案:

答案 0 :(得分:1)

您只需添加以下内容:

self.preferredContentSize = <view size>

到弹出窗口中显示的每个视图控制器中的viewWillAppear:方法。