我的应用程序是基于文档的应用程序我使用UIViewController子类EditViewsController在我自定义的UIDocument对象的帮助下呈现保存的内容。
EditViewsController将如下所示
点击左上角的关闭按钮将触发以下方法
-(IBAction)closeForm:(id)sender
{
// _formDocument is my UIdocument subclass Object
[_formDocument closeWithCompletionHandler:^(BOOL completion){
[self dismissViewControllerAnimated:YES completion:nil];
}];
}
我的问题是,在调用方法closeWithCompletionHandler
时,我的应用程序会在关闭之前冻结一段时间。
我的问题是,在不关闭文档的情况下解除视图控制器是正确的(只需在触发方法中调用dismissViewControllerAnimated:
)或者我必须在后台线程中运行该方法以摆脱
冷冻?
答案 0 :(得分:0)
-(IBAction)closeForm:(id)sender
{
// _formDocument is my UIdocument subclass Object
[_formDocument closeWithCompletionHandler:^(BOOL completion){
[NSOperationQueue mainQueue] addOperationBlock:^{
// Dismissing it on main thread
[self dismissViewControllerAnimated:YES completion:nil];
}];
}];
}