Questions tagged [swiftui-view]

For questions about View - a component in Apple's SwiftUI framework that represents part of your app’s user interface and provides modifiers that you use to configure views.. When using this tag also include the more generic [swiftui] tag where possible.

64 questions
1
vote
1 answer

Use of array generated through user input in another view

I want to do a project in which a user can write down names in one view. In another view a random name out of these is shown as a text to the user. I tried doing this with normal referencing, but the array with all the names, that is in the first…
Faker HD
  • 21
  • 2
1
vote
1 answer

Passing List between Views in SwiftUi

I'm making a ToDo list app on my own to try to get familiar with iOS development and there's this one problem I'm having: I have a separate View linked to enter in a new task with a TextField. Here's the code for this file: import SwiftUI struct…
NRGX
  • 19
  • 4
1
vote
1 answer

SwiftUI ScrollView doesn't compute custom StaggeredGrid height

I am trying to create a new grid structure in SwiftUI to show cards with variable heights. To that extent, I use several LazyVStacks in a HStack and have a condition to display my data items in the correct order. This view works alone, adapts the…
1
vote
2 answers

How can I apply an overlay to an entire SwiftUI container view's children?

I am trying to understand how to use container views in SwiftUI. I am expecting this - But when I run my app I get - How can I wrap all the child views? I am currently creating the views using the following - struct InfoCallout: View…
Teddy K
  • 820
  • 1
  • 6
  • 17
0
votes
0 answers

SwiftUI View Body Opaque type is accepting two concrete types

As SwiftUI View body attribute has a opaque type 'some View' so it should not allow two concrete types to be returned. But in my case, it's not giving error. struct TestOneView: View { var body: some View { if 1 != 1 { …
Aaban Tariq Murtaza
  • 1,155
  • 14
  • 16
0
votes
0 answers

OnTapGesture ALWAYS registers out of frame or view

I'm new to Swift, trying to do a personal project and I currently am stuck at a thing for which I cannot find a resolution anywhere for the past week. This is the code: import SwiftUI struct MainStatsView: View { var stat: StatElements …
0
votes
1 answer

I want to play a sound while navigating without it getting cut short

I have a main menu view that includes a navigation link. When I press "play," it navigates to the game screen and plays a sound. However, the sound only plays for a second and then cuts off for the rest of the navigation. I need help to make the…
0
votes
1 answer

SWIFTUI ViewModifier using UIViewRepresentable; getting a value from the UIView to my SwiftUI View

I have a custom modifier on a SwiftUI View to pan and zoom an Image. I need to get the location where the user long presses. The modifier uses an UIView (UIViewRepresentable) under the hood where the pinch-and-zoom gesture is added to the view.…
0
votes
2 answers

Conflicting arguments to generic parameter Content, RowContent when using a custom view is used inside List and NavigationView

I'm trying to create a simple ToDo App for practice. I created a DataModel for struct Task and tried to use it to iterate in a List in a NavigationView. When I write code like this, it works fine. import SwiftUI struct ContentView: View { var…
Buddha
  • 4,339
  • 2
  • 27
  • 51
0
votes
2 answers

SwiftUI how to enable interaction on a masked overlay in only the portion that is masked

I have added mask in a overlay to create a spotlight effect in SwiftUI. But at the same time I want the user to interact with the view through that window opening that I have such as sliding a slider or tapping a button while totally block other…
Asadullah Ali
  • 1,056
  • 14
  • 31
0
votes
1 answer

SwiftUI animated background view adjust width according to size changes (orientation)

I have an animated background view which is a struct (the view) that instantiates a class. It represents stars animating and moving from right to left on the screen. The view (StarsView) is given a width on creation. However, on size changes (like…
DeveloperSammy
  • 167
  • 1
  • 11
0
votes
1 answer

How do I stop SwiftUI's .resizable() adding a space when an assets catalog image doesn't exist?

I am building a rather long quiz app. Some questions have images and others don't. All the images are locally stored. I want to dynamically show an image if it exists in the local assets catalog. For those questions that do not have an image, I…
0
votes
1 answer

How to refactor almost identical conditional code in SwiftUI view

I have the following that I'm using for an input field where the user can enter an API token. By default it's presented as a SecureField, but the user can click the "eye" icon and change to a regular field struct PasswordField : View { …
chasepeeler
  • 137
  • 8
0
votes
1 answer

Moving parts of a SwiftUI List closer together

Is it possible to, somehow, move the text and the system image of a Label to be somewhat closer together? Label("MyString", systemImage: "wifi")
narner
  • 2,908
  • 3
  • 26
  • 63
0
votes
1 answer

Showing a view within a VStack causes other views within VStack to resize

I have a VStack of views which serve to act as a list of expanding rows. As you tap on any row, it expands to show further details. So long as I only have one row "expanded" at a time, everything works properly. However, if I "expand" 2 rows, then…
RealCasually
  • 3,593
  • 3
  • 27
  • 34