Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 第一响应器阵列回路swift_Arrays_Swift_Foreach_Swiftui_First Responder - Fatal编程技术网

Arrays 第一响应器阵列回路swift

Arrays 第一响应器阵列回路swift,arrays,swift,foreach,swiftui,first-responder,Arrays,Swift,Foreach,Swiftui,First Responder,试图压缩一些代码,这几乎是一堆复制和粘贴。它是一个数字框,每个框只有1个字符。它的工作原理与当前一样,输入1个字母后,光标将跳转到下一个框,依此类推,但代码非常重复,感觉质量很低 我已经设法将状态合并为单个数组,现在想尝试使用ForEach循环生成6个字段,但是当我这样做时,firstresponder没有响应 ForEach(0..

试图压缩一些代码,这几乎是一堆复制和粘贴。它是一个数字框,每个框只有1个字符。它的工作原理与当前一样,输入1个字母后,光标将跳转到下一个框,依此类推,但代码非常重复,感觉质量很低

我已经设法将状态合并为单个数组,现在想尝试使用
ForEach
循环生成6个字段,但是当我这样做时,
firstresponder
没有响应

ForEach(0..<6){i in
如果self.containerInputArray[i]!=”∂" {
TextField(“,text:self.$containerInputArray[i+1])
.框架(宽度:70,高度:零)
.font(字体系统(大小:40))
.onAppear{self.containerArray[i+1]=“”}
.introspectTextField{可在
如果self.containerPutArray[i]!=“”&self.containerBools[i]{
self.disposable?.resignFirstResponder()辞职
一次性。成为第一反应者()
self.containerBools[i]=false
} 
} 
}
}
如果我在手动索引中使用了6次,上面的部分就可以正常工作,但是当我使用循环时,它就不起作用了,为什么以及如何解决这个问题?或者有没有更好的方法来实现这一点(我在搜索中找不到类似的东西)