gpt4 book ai didi

ios - SwiftUI 文本字段 : Keyboard does not show up on tapped

转载 作者:行者123 更新时间:2023-12-05 06:52:23 25 4
gpt4 key购买 nike

我在 HStack 中有一个简单的 TextField 和一个按钮

        HStack {
TextField("Level Name", text: $levelName)
.font(.title)
.padding(10)
.background(
RoundedRectangle(cornerRadius: 15)
.strokeBorder(Color.primary.opacity(0.5), lineWidth: 3))

Button(action: {

}) {
Text("Submit").font(.title)
}
}

单击文本字段不会在我的模拟器上显示键盘,并给出控制台警告:

[LayoutConstraints] Unable to simultaneously satisfy constraints.Probably at least one of the constraints in the following list is one you don't want.Try this:(1) look at each constraint and try to figure out which you don't expect;(2) find the code that added the unwanted constraint or constraints and fix it.(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)("<NSAutoresizingMaskLayoutConstraint:0x600002bba8f0 h=--& v=--& _UIButtonBarButton:0x7fdbcbc52e90.height == 0 (active)>","<NSLayoutConstraint:0x600002bb4050 _UIUCBKBSelectionBackground:0x7fdbcbc53890.bottom == _UIButtonBarButton:0x7fdbcbc52e90.bottom - 6 (active)>","<NSLayoutConstraint:0x600002bbff70 V:|-(6)-[_UIUCBKBSelectionBackground:0x7fdbcbc53890] (active, names: '|':_UIButtonBarButton:0x7fdbcbc52e90 )>")

Will attempt to recover by breaking constraint<NSLayoutConstraint:0x600002bb4050 _UIUCBKBSelectionBackground:0x7fdbcbc53890.bottom == _UIButtonBarButton:0x7fdbcbc52e90.bottom - 6 (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.

最佳答案

您的代码有效。键盘出现。运行 iOS 15.1。

struct TestView: View {

@State var levelName = ""

var body: some View {

HStack {
TextField("Level Name", text: $levelName)
.font(.title)
.padding(10)
.background(
RoundedRectangle(cornerRadius: 15)
.strokeBorder(Color.primary.opacity(0.5), lineWidth: 3))

Button(action: {

}) {
Text("Submit").font(.title)
}
}

}

}

关于ios - SwiftUI 文本字段 : Keyboard does not show up on tapped,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65974942/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com