Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I have an image 32x32 and I want to fill the whole screen with many images
So I thought I could use ForEach but it doesn't seem to work
ForEach(0..<5) {_ in
Image("myImage")
}
this code creates 5 previews instead of 5 images
The problem is that you need to embed the code inside a Vstack or an Hstack.
That way it will know how to create those images (vertically or horizontally)
Vstack(spacing: 0) {
ForEach(0..<5) {_ in
return Image("myImage")
}
}
You need to use VStack or HStack You can't do that. For more info just take a look on the Apple Documentation. Here in Make the List Dynamic you will get the information.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 22 hours ago.
Improve this question
Consider the following code, which lists fruits. Is #EnvironmentObject the de-facto and recommended way of handling this scenario?
Is there a way to protect against the fact that you may get a runtime crash here, if the environment object hasn't been injected in?
Would you consider #EnvironmentObject to essentially be a singleton (if set at a high enough level in the view hierarchy) and therefore inherently bad (mutable state everywhere being 'bad').
struct FruitsView: View {
#EnvironmentObject var merchant: Merchant
var body: some View {
NavigationStack {
ForEach($merchant.fruits, id: \.id) { $fruit in
NavigationLink(destination: FruitDetailView(fruit: $fruit)) {
Text(fruit.name)
}
}
}
}
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 months ago.
Improve this question
How do I remove this icon?
I am using very simple code; just navigation view
As mentioned in the comments by #Nirav D, this button is used to toggle the sidebar visibility.
iOS 16 & above
In iOS 16, Apple gave Navigation a big refresh:
Introducing NavigationStack(which is probably what you want), it is used to present a view allowing the user to navigate using NavigationLink as you would on an iPhone.
Introducing NavigationSplitView(which is what you’re seing in the simulator right now), it is used to present a menu (sidebar) that can present detail views. You can have up to 3 columns.
Deprecating NavigationView, from now on you have to use the above containers as NavigationView will be obsoleted in a future iOS release.
iOS 15 & below
In versions earlier than 16, you have to use NavigationView. NavigationView accepts navigationViewStyle, the default style on iPhone is StackNavigationViewStyle where the content is presented in one column. However, on iPad in order to maximise the use of screen estate, SwiftUI sets the default style to ColumnNavigationViewStyle that presents the content in columns (Master -> Detail…).
If you mean to use a single column: you must use either NavigationStack or NaigationView with .navigationViewStyle(.stack);
If you have to use multiple columns & still hide the button: use .navigationBarHidden(true) on the sidebar view, or .toolbar(.hidden, for: .navigationBar) for iOS 16+.
For more info, check: Navigation & The SwiftUI cookbook for navigation
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I am a Visual Studio MFC newbie, and have been a bit perplexed by a problem over the last couple of days. When I create a radio button and assign it variable, I get a "Debug Assertion Failed". How should I make the radio button a variable?
You have to make sure that the first radio button in a sequence of radio buttons is of style WS_GROUP. It is a style you can set in the dialog editor by selecting the first radio button and setting its style to Group.
You want to use an int as the type to receive/set and only use DDX_Radio() on the first radio button on the group. It will return 0 if first radio selected, 1 if second, 2 if third, etc... Make sure the value you use, a member variable is initially set to 0 or another valid value.
This question already has answers here:
Implement dark mode switch in SwiftUI App
(9 answers)
Closed 1 year ago.
Is it possible in SwiftUI to force a View to use light or dark mode — like overrideUserInterfaceStyle in UIKit does?
.colorScheme() is deprecated does not work with the background well.
.preferredColorScheme() is the way now. Does the job with the background too.
TestView1()
.preferredColorScheme(.dark)
TestView2()
.preferredColorScheme(.light)
Developer docs for .preferredColorScheme()
Use .colorScheme modifier, like
TestView1()
.colorScheme(.dark)
TestView2()
.colorScheme(.light)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
i need to display Product Weight under Product price in the single product page & search page on OpenCart 3.0.2.0 .
How i can do that ?
This is relatively simple if you understand the MVC (Model, View, Controller) pattern. Here are the steps required:
You need to add the logic for fetching the product weight in the controller file and pass it to the view catalog/controller/product/product.php
On line 283 (right after the price because it is a nice place for it) add this code
$data['weight'] = $product_info['weight'] + 0 ;
(the + 0 removes the zeros and makes it looks nicer)
Then you need to display it in your view template file catalog/view/theme/default/template/product/product.twig
on line 162 add:
{{weight}}
If you don't see the changes, that is because you have twig Cache turned on. Go to admin/dashboard and on the top right corner find the gear button. click it and click refresh cache. you can also turn off the cache while you are in development mode. http://joxi.ru/LmGewYZiwBW0zA