简体   繁体   English

导航时UIPopoverController出现问题

[英]problem with UIPopoverController while navigation

I have UIPopoverController and two ViewController class. 我有UIPopoverController和两个ViewController类。

SaveProject and ProjectName is viewController class. SaveProject和ProjectName是viewController类。

When i am clicking save project. 当我单击保存项目时。 its give me navigation and load another view. 它给我导航并加载另一个视图。

But the UIPopoverController size height is getting increased to the total view size. 但是UIPopoverController的大小高度正在增加到总视图大小。

Can any one help me out with this.. 谁能帮我这个忙..

I am attaching here code: 我在这里附上代码:

-(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;

    }
}

在此处输入图片说明

You just need to add something like: 您只需要添加以下内容:

self.preferredContentSize = <view size>

to the viewWillAppear: method in each of your view controllers that are displayed in the popover. 弹出窗口中显示的每个视图控制器中的viewWillAppear:方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM