I am wanting to have two editable TextFields sitting next to each other on an iOS app in an HStack. However, I get an error ("Static member 'leading' cannot be used on instance of type 'HorizontalAlignment'") whenever I put this into my View file:
var body: some View {
VStack(alignment: .leading) {
...
VStack(alignment: .leading) {
HStack {
TextField("\(aCountry.populationTitle)", text: $aCountry.populationTitle)
TextField("\(aCountry.population)", text: $aCountry.population)
}...
This also happens if I have one TextField and two or more Text items in the same HStack.
Possible solution or reason as to why this happens? If I remove one of the TextFields or have only one TextField and one Text item in the same HStack, the app runs smoothly (no errors).
Using xcode11.4.
Thanks.
[EDIT]
Body for MasterView.swift:
struct DetailView: View {
@ObservedObject var aCountry: Country
var body: some View {
VStack(alignment: .leading) {
Image("\(aCountry.imageName)").resizable().frame(width: 200, height: 200)
TextField("\(aCountry.name)", text: $aCountry.name)
.font(.headline)
TextField("\(aCountry.continent)", text: $aCountry.continent)
.font(.subheadline)
VStack(alignment: .leading) {
HStack {
TextField("Population:", text: $aCountry.populationTitle)
TextField("\(aCountry.population)", text: $aCountry.population)
}
}}}