如何在页面已加载后,如何在uitextfied中设置值
我有一个本机iOS项目,我们在其中整合了React Native。在这里,我们有一个本机iOS(Swift)和屏幕B中的屏幕A中的反应本地。 当用户在屏幕中时,单击组件并导航到屏幕B。在屏幕B中,用户选择一个选项并将该值传递给使用NativeModules之间的两个部分之间的brigde。 在该屏幕B被解散之后,用户再次能够看到屏幕A。可以在屏幕上的函数中访问通过桥梁的值,但是当试图将该值设置为UITEXTFIELD获取错误时 :在隐式解开可选值
时,意外发现了nil
线程1:致命错误
I have a native iOS project in which we have integrated react native. Here we have a screen A in native iOS(swift) and screen B in React-native.
When user is in screen A clicks on component and navigated to screen B. Inside screen B then user selects a option and passes that value to brigde between the two parts using NativeModules.
After that screen B gets dismissed and user is again able to see the screen A. The value which is passed through bridge can be accessed inside a function in screen A view controller, but when trying to set that value to UITextField getting error Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
Expecting to set the value which is received from screen B in screen A gets saved in UITextField to be utilised further
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这意味着您尝试使用零的对象。
例如,您有一个TextField对象(Uitextfield的类型),并且您尝试使用:
尚未初始化Textfield。没有代码,很难说出什么问题,但是要么您之前应该在某个地方进行过启动文本字段:
或者您应该安全地解开字段,然后尝试设置该值 - 如果零,则仍然不会设置它。
This means that you tried to use an object which is nil.
E.g. you had a textField object (type of UITextField) and you tried to use:
Your textField is not yet initialized. Without code it's hard to say what's wrong but either you should have initilaized textField somewhere before:
Or you should safely unwrap the field and try to set the value - if it's nil it still won't be set.