对至少未渲染过一次的视图 (_UIReplicantView) 进行快照需要 afterScreenUpdates:YES [英] Snapshotting a view (_UIReplicantView) that has not been rendered at least once requires afterScreenUpdates:YES

查看:80
本文介绍了对至少未渲染过一次的视图 (_UIReplicantView) 进行快照需要 afterScreenUpdates:YES的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个仍在学习的新程序员,所以如果我的代码看起来像废话,请原谅我.我正在编写一个程序,它有一个名为infoViewController"的 ViewController,上面有多个 UITextFields.用户应该填写文本字段,然后单击屏幕右上角的下一步"按钮,然后激活显示"转场并将它们带到下一个 VC.来自文本字段的所有信息都存储在常量中,以便以后我获取他们输入的信息并将其放在最后生成的 .PDF 文件中.我希望用户能够轻松浏览文本字段,因此我将其设置为当用户在 TextField 上并单击键盘上的下一步"时,它将它们移动到下一个 TextField,以便他们可以将它们全部填满快速轻松地出来.我遇到的问题是,由于某种原因,当我单击键盘上的下一步"时,我不断收到此错误:

I'm a new programmer that's still learning, so forgive me if my code looks like crap. I'm writing a program that has a ViewController called "infoViewController" with multiple UITextFields on it. The user is supposed to fill out the textfields and then click the "Next" button in the upper-right of the screen, which then activates a "Show" segue and takes them to the next VC. All the info from the Text Fields are stored in constants for later down the road when I take that information that they inputted and place it on a .PDF file that is generated at the end. I wanted the user to be able to easily go through the text fields, so I made it where when the user is on the TextField and clicks "Next" on their keyboard, it moves them to the next TextField so that they can fill them all out quickly and easily. The issue I run into is that for some reason I keep getting this error when I click "Next" on the keyboard:

[Snapshotting] 对至少未渲染过一次的视图 (0x7f8995578​​6c0, _UIReplicantView) 进行快照需要 afterScreenUpdates:YES.

该应用程序仍然有效...但我宁愿在面板(在 Xcode 中)中完全没有显示错误,哈哈.此外,当它执行此操作时,它就像在移动到下一个 TextField 之前屏幕出现故障并闪烁白色一瞬间(超快)......有什么解决方案?

The app still works... but I'd rather not have an error showing up in the panel (in Xcode) at all lol. Also, when it does this, it's like the screen glitches and flickers white for a split second (super fast) before it moves on to the next TextField... any solutions?

请将您回复的任何内容都简化为初学者级别.谢谢!

Please dumb anything you reply down to a beginners level. Thanks!

这是我为在 TextField 之间切换而编写的代码:

Here's the code I wrote for switching between TextFields:

扩展信息视图控制器{

func textFieldShouldReturn(_ textField: UITextField) -> Bool {
    let nextTag = textField.tag + 1

    if let nextResponder = textField.superview?.viewWithTag(nextTag) {
        nextResponder.becomeFirstResponder()
    } else {
        textField.resignFirstResponder()
    }

    return true
}

}

我在viewDidLoad"中分配了 TextField 委托.(例如:clientTextField.delegate = self)

I assigned the TextField delegates in "viewDidLoad." (Ex: clientTextField.delegate = self)

我还在viewDidLoad"中分配了标签.(例如:clientTextField.tag = 0)

I also assigned the tags in "viewDidLoad." (Ex: clientTextField.tag = 0)

推荐答案

每当 textField 切换 firstResponders 时,我都会收到同样的警告.但这仅适用于将文本输入大写特征"设置为无"以外的任何内容的文本字段.

I had the same warning whenever a textField switched firstResponders. But this only happened for textFields that had the Text Input Trait of Capitalization set to anything other than None.

文本输入特征可以在属性检查器中的最小字体大小下找到.

Text Input Traits can be found in the Attributes Inspector under Min Font Size.

就我而言,将大写的文本输入特征更改为无消除了该警告.虽然这对我有用,但我认为这只能解决一个症状,而不是根本问题.

In my case, changing Text Input Trait of Capitalization to None removed that warning. While this worked for me, I imagine this only solves a symptom, not the underlying problem.

这篇关于对至少未渲染过一次的视图 (_UIReplicantView) 进行快照需要 afterScreenUpdates:YES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆