UIWindow直到方法完成才显示

时间:2016-10-20 18:11:10

标签: ios objective-c uiwindow

我试图显示视图,因为该方法需要几秒钟才能完成。但是,在整个方法完成之前,加载UIWindow实际上并不是键和可见的。知道这里发生了什么吗?

// this line creates a uiwindow with view controller as root view controller, an activity indicator, and a label and makes the loading view key and visible
[XSELLoadingView presentLoadingViewWithTitle:@"Generating Report"]; // use loading view for long times

// these three lines process a lot of data and present the view on the main window
XSELCount *startCount = [[XSELCount counts] objectAtIndex:[self.startingPick selectedRowInComponent:0]];
XSELCount *endCount = [[XSELCount counts] objectAtIndex:[self.endingPick selectedRowInComponent:0
[self.navigationController pushViewController:[XSELReportView viewWithReportData:[XSELReportData compareStartCount:startCount toEndCount:endCount]] animated:false];   

// this line makes the main view key and visable 
[XSELLoadingView dismissLoadingView];

1 个答案:

答案 0 :(得分:0)

Apply your task inside this one.

 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    //Do background work
    dispatch_async(dispatch_get_main_queue(), ^{
        //Update UI
    });
});