在app kill和resume之后会短暂显示UIPopover

时间:2013-11-25 22:33:29

标签: ios objective-c ipad popover

我正在尝试应用状态保存&在iPad应用程序中恢复,但如果弹出窗口打开,那么在恢复期间,它会被短暂显示然后隐藏。这是由连接弹出窗口的主视图控制器的viewDidLoad中的代码执行引起的。此代码需要一些时间来执行,并在Web视图中加载html文件。因此,当Web视图最终加载html文件时,popover消失。我可以阻止弹出窗口隐藏而不将viewDidLoad代码移到别处吗?

期待您的帮助!

- (void)viewDidLoad
{
    [super viewDidLoad];

    text = [NSString stringWithContentsOfFile:file encoding:NSUTF8StringEncoding error:&error];

    NSString *path = [[NSBundle mainBundle] bundlePath];

    NSURL *baseURL = [NSURL fileURLWithPath:path];

    [webview loadHTMLString:text baseURL:baseURL];

}

这是单击条形按钮项目时运行的代码。 但是,当应用程序恢复时,前面打开的弹出窗口会出现问题。

- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender {

    if ([identifier isEqualToString:@"filterPopover"]) {

        if (self.filterPopover == nil && self.prefsPopover == nil) {
            return YES;
        }
        return NO;
    }

    if ([identifier isEqualToString:@"prefsPopover"]) {

        if (self.prefsPopover == nil && self.filterPopover == nil) {
            return YES;
        }
        return NO;
    }

    return YES;
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    if ([segue.identifier isEqualToString:@"filterPopover"]) {
        // Assign popover instance so we can dismiss it later
        self.filterPopover = [(UIStoryboardPopoverSegue *)segue popoverController];
        // assign delegate for popover dismiss purpose
        self.filterPopover.delegate = self;
        filterPopOverVisible = true;
    }

    if ([segue.identifier isEqualToString:@"prefsPopover"]) {
        // Assign popover instance so we can dismiss it later
        self.prefsPopover = [(UIStoryboardPopoverSegue *)segue popoverController];
        // assign delegate for popover dismiss purpose
        self.prefsPopover.delegate = self;
    }
}

0 个答案:

没有答案