Post

Replies

Boosts

Views

Activity

How can I create a view with a mixture of Text and TextFields dynamically in SwiftUI
The issue I am encountering is, I need to be able to create a view in SwiftUI that looks like a sentence of text but has blanks where the user can enter their own text. I also need a way to be able to capture the entered text from the binding, but not sure how to do multiple bindings in a loop. Ive tried a few options and the closest I have got is using LazyGrid, but it doesn't look like a normal sentence due to spacing? Any help appreciated. struct MultiText: View { @State var text = "There was once a {-} that only had {-} in it. How did they get in? {-}" @State var answerText: String = "XXXXXXX" let rows = [ GridItem(.adaptive(minimum: 80)) ] var body: some View { GeometryReader { geo in HStack { LazyVGrid(columns: rows, alignment: .leading, spacing: 0) { ForEach(text.components(separatedBy: " "), id: \.self) { component in if component == "{-}" { TextField("", text: $answerText ) } else { Text(component) } } }.frame(width: geo.size.width * 0.80) Image(systemName: "flag").frame(width: 30, height: 30) }.frame(width: geo.size.width) } } } This produces the following result
0
0
266
Jul ’23
SwiftUI update Map region causes warning about Modifying state.
I have a project that uses the new SwiftUI Map in iOS 14 I want to be able to update the location of the Map centre dynamically. When you tap the Zoom button and then the Location Button the Map works fine and re-centers to London. However if you just tap the location button it re-centers to London but throws a warning about the ViewState. I am at a loss for what is causing this issue and how to fix it.     @State private var region = MKCoordinateRegion(         center: CLLocationCoordinate2D(             latitude: 25.7617,             longitude: 80.1918         ),         span: MKCoordinateSpan(             latitudeDelta: 10,             longitudeDelta: 10         )     )     var body: some View {         VStack {             Map(coordinateRegion: $region)             Button("zoom") {                 withAnimation {                     region.span = MKCoordinateSpan(                         latitudeDelta: 100,                         longitudeDelta: 100                     )                 }             }             Button(action: {                 withAnimation {                     region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 51.507222, longitude: -0.1275), span: MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5))                 }             }) {                 Image(systemName: "location.fill")                     .frame(width: 44, height: 44, alignment: .center)                     .foregroundColor(.black)                 .background(Color(.white))             }.buttonStyle(PlainButtonStyle())             .clipShape(Circle())             .shadow(color: .black.opacity(0.5), radius: 1.0, x: 0.0, y: 2.0)         }     } }
0
1
1.3k
Jul ’21
App Store Logo on apple preview site distorted.
Anyone know how to solve this ? When viewing the app preview page on some browsers the App Logo is distorted, as if it's been show 3 times. https://apps.apple.com/us/app/victvs-v3/id1517808719 It seems to work fine on Safari, but not on Chrome or Edge. Is this a bug that needs to be fixed by Apple or something I may have done on the App upload. Ive checked the image file formats and the guidelines in the HIG and the icons fit in with the guidelines. Any ideas ?
3
0
838
Oct ’20
App Review
When I try to submit my App for review. I get the following message. You must upload an iMessage screenshot for 6.5-inch iPhone displays. I get this for all screen sizes. However my App isn't using iMessage ? Anyone know what it means and how to solve it ?
3
0
870
Jun ’20