刚开始使用Xcode 4.5,我在控制台中遇到了这个错误:
警告:尝试在<ViewController:0x1ec3e000>上显示<finishViewController:0x1e56e0a0>,其视图不在窗口层次结构中!
该视图仍在呈现中,应用程序中的所有内容都正常运行.这是iOS 6中的新功能吗?
这是我用来在视图之间切换的代码:
UIStoryboard *storyboard = self.storyboard;
finishViewController *finished =
[storyboard instantiateViewControllerWithIdentifier:@"finishViewController"];
[self presentViewController:finished animated:NO completion:NULL];
Run Code Online (Sandbox Code Playgroud) 我正试图在我的游戏上创建一个暂停屏幕.我在故事板中添加了一个'PauseScreen'viewController,故事板ID和Restoration ID设置为"PauseScreenID",并移动到暂停屏幕我已在"GameScene"中创建了该功能:
func pauseSceenTransition(){
let viewController = UIStoryboard(name: "Main", bundle:nil).instantiateViewControllerWithIdentifier("PauseScreenID") as UIViewController
let currentViewController = (UIApplication.sharedApplication().delegate as AppDelegate)
currentViewController.window?.rootViewController?.presentViewController(viewController, animated: false, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
但是当它被调用时,我得到错误:
警告:尝试在< AppName .StartScreenViewController:0x7fae61f79980>上显示< AppName .PauseScreen:0x7fae61fe5ff0>,其视图不在窗口层次结构中!
"StartScreenViewController"是我的开始屏幕的视图控制器,是初始视图控制器.然后转到"GameScene",这是"PauseScreen"需要去的地方.如果我将初始视图控制器设置为"GameViewController"/"GameScene",它可以工作,所以我认为我需要更改第二行:
let currentViewController = (UIApplication.sharedApplication().delegate as AppDelegate)
Run Code Online (Sandbox Code Playgroud)
所以它在"GameViewController"上呈现"PauseScreen",而不是"StartScreenViewController",但我不知道该怎么做.
我正在使用,swift 4并且尝试alertView使用进行用户注册时出错时尝试创建一个Firebase。我有一个IBActionfor sign up按钮,它将使用两个文本来注册用户textfields,一个用于电子邮件,一个用于密码。
我基本上是在尝试显示alertview注册过程中出现错误时(例如,有一个Empty)textfield。
我将函数的屏幕快照附加到发生的地方。我知道我实际上遇到了错误,因为如果有一个print语句,则会输出一个错误。
无论是否存在错误,都不会显示警报视图,并且该应用程序会执行segue。
2019-01-15 21:40:26.368924-0500 Pronto [9036:225268]警告:尝试呈现其视图不在窗口层次结构中的视图
这是我现在显示的alertview的输出。我看过所有其他关于同一问题的文章,但似乎都没有。
我正在尝试在线程中打开文件,这是我的代码:
DispatchQueue.main.async(execute: { () -> Void in
var documentsURL = (FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)).appendPathComponent(“File.pdf")
self.docController = UIDocumentInteractionController.init(url: documentsURL as URL)
self.docController?.delegate = self as? UIDocumentInteractionControllerDelegate
self.docController?.presentPreview(animated: true)
self.docController?.presentOpenInMenu(from: CGRect.zero, in: self.view, animated: true)
})
Run Code Online (Sandbox Code Playgroud)
当移动到主屏幕时,会显示此警告并且文件未打开
Warning: Attempt to present <_UIDocumentActivityViewController: 0x...> on <HCM.PrintVacationDecisionVC: 0x...> whose view is not in the window hierarchy!
Run Code Online (Sandbox Code Playgroud)
有什么帮助解决这个问题?