I'm building my first SwiftUI app. For some reason when I command+click on an HStack the "Extract Subview" and other options don't show up. Any reason why I'm not seeing these options? I'm using Core Data and UITableView.appearance to remove lines in my List as well. Does it have to do with using core data and my use of UITableView? Couldn't find any answers after researching. Appreciate the help.
Not sure if this is an Xcode issue/bug but as of Xcode 11.4 the "Extract Subview" option (and others) show up only if the Canvas
is being shown.
So, enable live preview and then cmd-click on the View
you want to extract.
.environment(\.managedObjectContext, context)
in the PreviewProvider
. –
Education Composing our UI
section and your live preview should work alongside Core Data ;) –
Education I was having the same problem but could not solve it with the presented solution. Came to realize that you need to have an Object embedded in another to be able to extract it. In the example below, I would not be able to extract the HStack, but it will show up in the VStack.
struct ContentView: View {
var body: some View {
HStack(){
Image("sal")
.resizable()
.frame(width: 100, height: 100)
.aspectRatio(contentMode: .fit)
.cornerRadius(20)
.padding(.trailing)
VStack(alignment: .trailing){
Text("Camino La Angostura")
Text("2.5 Km.")
}
}
}
}
Try Control + Right Click.
Your welcome!
I got the same problem. You should do command + right click.
I had same issue and I found the Extract subview option.
Follow the following steps:
- Double click on curly braces
- Right click on selected item
- Now you can see the all options
Please check these screenshot:
I was encountering the same problem and then I find a suggestion here that seems to solve it, basically you need an object embedded in another for it to work, for instance an hstack inside a vstack.
© 2022 - 2024 — McMap. All rights reserved.