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)
}
}
}
}
}
Related
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 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 2 years ago.
Improve this question
I'm trying to customize Sales 365. I need a field in a Lead form to multiselect items from Account View.
Is there any way to do it without coding?
Thanks
You can't have a field but you can have a subgrid, relationship between Lead and Account will be N:N, in this way the user can select multiple records from the Account entity.
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.
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 4 years ago.
Improve this question
I want escape html for data in controller, I found 2 ways:
text.gsub('<', '<').gsub('>', '>')
OR
CGI.escapeHTML(text)
What is the best, why?
The best way is probably to just assign the data to instance variables and then output them in the view, which will handle encoding automatically:
controller:
def something
#foo = "<test>"
end
something.html.erb
<%= #foo %>
Will output:
<test>
The view will do the right thing in most cases.
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 8 years ago.
Improve this question
There is a file megamenu.less and I passed to the point where I can get bigger buttons but I am not able to add color to the buttons and make dropdown look nicer.
What code should I add to my template.less?
Thank you very much!
Please try to add in your template.css line 2507:
nav.zo2-menu .navbar-nav > li > a { padding: 20px; }
You also have to add at the end of the file:
.nav.navbar-nav.level-top a { background: none repeat scroll 0 0 #72b626 !important; }
Good luck!