Post

Replies

Boosts

Views

Activity

Reply to Why is the Button not working? SwiftUI
try the following, It gets rid of the layout constraint issues and shows the My Text Label, using an EmptyView as the destination and the help button in the navbar. There is a certain view hierarchy that must be kept to avoid layout issues. struct ContentView: View {     @State var selection: String?     let id = "1"     var body: some View {         test     }     var test: some View {         NavigationView {             NavigationLink(tag: id, selection: $selection) {                 EmptyView()                     .navigationTitle("Welcome")             } label: {                 Text("My Test")             }             .toolbar {                 Button("Help") {                     print("Help tapped!")                 }             }         }     } Example two without the NavigationLink struct ContentView: View {     var body: some View {         nonavLink     }     var nonavLink: some View {         NavigationView {             Text("My Test")             .toolbar {                 Button("Help") {                     print("Help tapped!")                 }             }         }         .navigationTitle("Welcome")     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’22
Reply to Xcode 13.2.1 Preview
Notes The command below also works with 13.x.x https://developer.apple.com/documentation/xcode-release-notes/xcode-13_3-release-notes Xcode SwiftUI Previews may occasionally fail with an error message about a modified .hfile, such as “file Header.h has been modified since the module file Module.pcm was built: mtime changed.” (85938686) Workaround: Delete the Clang module cache by running the following command in Terminal: rm -rf "$TMPDIR/../C/clang/ModuleCache". Then try to preview the file again.
Feb ’22
Reply to How can I refactor a GeometryReader?
Value types in swift cannot be subclassed because they are not objects nor are they class types. You can try extending with the use of extensions but the internal behaviours of the components are private APIs except for what is already available as public APIs.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’22