128 questions
0
votes
2
answers
110
views
How to Eliminate Form Padding in NavigationStack
I have a form being loaded inside a navigation stack and I'm showing an image and title in the first form section with the code below:
Form {
Section {
VStack {
Image("...
1
vote
1
answer
133
views
Aligning controls in a Form
In my ongoing quest to understand the layout in a form, I decided to see if I can emulate the sidebar in the new Icon Composer app. I am focusing now on the rows with a title, switch and TextField. ...
0
votes
0
answers
69
views
Form Items inside scrollview randomly stops being clickable
I need view like this in order to have fixed size form with scrollable capability.
I have disclosure groups, buttons and textfields inside form.
struct ContentView: View {
var body: some View {
...
1
vote
1
answer
32
views
How to remove the box surrounding certain views in a .grouped style Form?
I am writing a .grouped-styled Form on macOS. For each section in the form, this form style puts a box/border surrounding it, almost like a .insetGrouped-styled List on iOS.
While this is desirable ...
0
votes
1
answer
51
views
List, form updating and cursor issue
I`ve adapt official Apple tutorial app for my needs.
There is a ContentListView that displays a list of recipes on one side and a form to edit the selected recipe on the other. The form includes a ...
0
votes
1
answer
188
views
How to remove padding between navigation bar title and first item of Form when using .inline display mode
I am trying to display a form as a sheet that contains some data entry items. I want to display the navigation title in .inline display mode. But there is a large gap between the navigation bar title ...
3
votes
1
answer
68
views
Give Form Section a Background Color/Gradient
This is my code:
Form {
Section {} // regular section no background
Section { // <--- want this section to have a background color
Text("Hello")
}
.background(Gradient(...
0
votes
0
answers
643
views
How to Handle multiple views with form input in SwiftUI and Obtain all input values with a button click - SwiftUI?
I hope you're all doing well. I am new to SwiftUI and I have been working on a form UI in SwiftUI. From a UI perspective, it looks correct, but I'm facing some issues. When I fill in some values in ...
3
votes
2
answers
4k
views
No tap animation when clicking a Button inside a Form in SwiftUI
I am using a Form in SwiftUI based on a tutorial from YouTube, and I have placed some components inside it. However, when I tap the button, it doesn't show the tap animation (For example, when I tap a ...
1
vote
1
answer
649
views
SwiftUI: Form pushes all navigation links on navigation stack
The idea is to use a Settings View in my App using a Form. However, it seems the Form itself pushes all NavigationLinks from the List view onto the navigation stack (at once). The typical (correct?) ...
4
votes
1
answer
1k
views
How to change the background color of a form?
I'm not able to change the background color of a Form in SwiftUI for iOS < 16. It always takes default form backgroundcolor depending on which color scheme is selected in the iPhone settings. All ...
1
vote
1
answer
1k
views
SwiftUI Form: Sheet isn't dismissed automatically when the view it's attached to is gone
See the code below (BTW, List has the same issue):
enum Value: String, Equatable {
case a = "a"
case b = "b"
}
struct ContentView: View {
@State var value: Value = .a
...
1
vote
1
answer
147
views
SwiftUI How to change Background Color of NavigationView with Form?
Is there possibility to change background color of this view?
Note: I dont want to change form sections color, i want to change background color of view.
`.background(Color.red) does not effect.
init()...
0
votes
2
answers
595
views
SwiftUI Stepper not working when bound to a model property directly
I am fairly new to iOS development. I am trying to update the property "cars" in the "Sire" model using a stepper. Whenever I press on + or - from the stepper controls, it changes ...
0
votes
1
answer
445
views
How do you remove the margin from the top of the screen to a form?
I have this space between the top of the screen and my text input box. How can I reduce this space? I don't want to bring the input box up too far as it will be obstructed by the notch. However, I ...
-1
votes
2
answers
2k
views
SwiftUI Form style changed when embedded in UIHostingViewController
I have A SwiftUI view which is a standard form and in canvas it has the built in IOS form style which is the look I desire.
However this form is being used a SideBar embedded in a ...
0
votes
1
answer
169
views
SwiftUI Form space between two buttons
I have a form with 2 buttons. Now I would like to have a little space between these two buttons. Exactly like in this example:
Does anyone know how to implement this?
I appreciate any help!
0
votes
2
answers
102
views
Swiftui form space and seperator bug
I would like to place 2 buttons one below the other with a bit space in a form. Just like in this example:
Currently it looks like this:
With this code:
Form {
Section {
...
-2
votes
2
answers
589
views
How do I create a certain number of TextFields based on User Input?
I want to create a certain amount of TextFields on a view based on the number the user inputs. For Example, if the user inputs 5 I would like to display 5 TextFields on the view. I was thinking about ...
3
votes
1
answer
2k
views
SwiftUI - can I make one element in Form fill the whole screen width (without horizontal margins)?
I would like a single item inside SwiftUI Form to run from side to side, without having Form's default margins.
Unfortunately, whatever I do (like ading a wider .frame, negative horizontal padding, or ...
1
vote
0
answers
1k
views
SwiftUI IOS: Editable list in a form?
I would like to make my list in a form editable and sortable with the editMode. I've already tried using .environment(.editMode, .constant(.active)) on the list or on the ForEach loop, but ...
0
votes
1
answer
1k
views
Display segmented Picker in Form without section background & padding
I want to display a picker with segmented style inside a form.
Form {
Section {
Picker("Picker", selection: $selectedOption) {
Text("Option 1")
...
0
votes
1
answer
588
views
How to conditionally render a SwiftUI Form with animation using the selection from a Segmented Picker?
I'm trying to conditionally render two Forms based on the selection from a segmented picker. It all works fine when there's no animations, but the moment I add them in, the first Form seems to break.
...
2
votes
1
answer
473
views
Need Bar Chart to fit inside Section()
New to SwiftUI. I have a simple form with two Section().
In one of the section, I have put BarChartView() from SwiftUICharts() as shown below.
The Bar chart does not fit in the section, needed help ...
0
votes
1
answer
322
views
Animations cause From view to break in SwiftUI
I have been trying to animate the transition between 2 views that contain Form views in SwiftUI. However the layout breaks only when the animation applies.
This is a fully reproducible example. (Only ...
1
vote
1
answer
863
views
.focused does not work if TextField is obscured by they iOS keyboard
EDIT:
After running @Yrb's code below, I realized the ForEach loop was a red herring. The actual issue here is that .focused will simply close the keyboard if you attempt to focus a field that is ...
0
votes
1
answer
368
views
Prefill textfields in SwiftUI is broken in iOS 15
In iOS 14 I've following code which prefills all textfields from the coredata model
struct EditSimpleSearchView: View {
@Environment(\.managedObjectContext)
private var viewContext
@...
0
votes
1
answer
60
views
Set a value to default which constantly changes
I am creating a game where I have a value of highscore which I want to save each time it is updated even if I exit the app. I have already the value of highscore which updates eveyrtime the score > ...
1
vote
2
answers
1k
views
Apply modifier to VStack inner views
I want to create a ViewModifier, which when applied to a VStack it makes its style look like a List inside a Form, as presented in the image below. I have multiple custom scenarios where Lists don't ...
0
votes
1
answer
349
views
How to use function from other struct/view in SwiftUI?
Newbie SwiftUI Dev here.
I want to create a scheduling app in SwiftUI and I would like to create a button in navigation bar which change calendar's scope.
From .week to month and return.
struct ...
0
votes
1
answer
1k
views
SwiftUI - Move text to Header when scrolling up
I want when I scroll up the Text ("Hello") will stay fixed, and the text "Welcome " will move up to be on the same line as Text("Hello").
Hope you can give me some ...
1
vote
1
answer
3k
views
Use section headers on SwiftUI Picker list?
I'm trying to get something similar to the following using SwiftUI and Picker()
But when I try to use Section(header: ) I get the following:
Form {
Picker("S", selection: $sensor) {
...
1
vote
1
answer
710
views
Random white line showing up between views when using Form
I've been messing with this for quite some time now and cannot for the life of me figure out where this little white line is coming from. I tried setting .padding(0) and using a .frame() but nothing ...
6
votes
5
answers
7k
views
Spacer not working with Form inside a VStack
I'm trying to get a circle on top with the form content down below, right above my TabBar. I can somewhat force this by using .frame() but I'm not a big fan of that. It seems like there should be a ...
1
vote
1
answer
660
views
NavigationView issue with "Form" Picker inside NavigationLink child
I have a trouble trying to put my Picker inside NavigationLink child struct.
MyProblem
As you see after some transition (Main Page -> Testing Page -> Picker) and choosing any pickers desire ...
9
votes
0
answers
401
views
SwiftUI, iOS 14, Keyboard Avoidance in Form{ TextEditor() }
I am having a problem on a simple Form{}. Automatic Keyboard Avoidance is not working. Below is a small form with a TextEditor(). When run, the keyboard sits on top the input field, requiring the user ...
6
votes
0
answers
547
views
SwiftUI toolbar covered by keyboard accessory view
Hi there I have a tricky problem to solve with SwiftUI in Xcode 12.4 (iOS 14): given I have a Form with numerous sections and TextEditors, this form having a .toolbar modifier (bottom bar) with some ...
1
vote
1
answer
3k
views
SwiftUI form section title and rows have incorrect formatting
The following SwiftUI form will render the section its header and contents incorrectly. The section header should be capitalized and have a background color. The rows should be marked up like a list, ...
2
votes
1
answer
3k
views
Swiftui view not updating list after data append to array
I have three files: AddAssignment, ViewAssignment and Task.
A button is clicked on AddAssignment.swift which successfully appends form data to an array inside of Task.swift.
However, in a file ...
6
votes
1
answer
8k
views
Swiftui Binding<String> action tried to update multiple times per frame
I am having trouble debugging an issue with input from textfields.
Information:
-MacOs Monterey Version 12.0 Beta 21A5284e
-Xcode 13.0 beta 3 13A5192j
-Physical phone IOS 15.0 19A297e
Issue ...
1
vote
1
answer
355
views
File importer/ File Mover methods are not getting invoked when using Form swift UI
even though the binding properties in fileMover are set to true. file mover is not getting executed. Below is the sample code i have used. Any leads will be helpful.
Thanks in advance.
var body: ...
9
votes
1
answer
7k
views
SwiftUI how to pass data to previous screen on dismiss
I want pass data on dismissing of presentViewController to previous screen. Here I would like to use block to pass data to previous screen as UIKitApp. But I'm not getting idea to pass data. What are ...
1
vote
2
answers
1k
views
Swift @Published causing didSet recursion
What is wrong with the following test code ? When I enter a character into the field, the didSet goes into a recursive loop. If the inout + & are removed, the code functions as expected with ...
0
votes
0
answers
121
views
SwiftUI: Convert entire content of Form to UIImage
Not able to get SwiftUI Form content size. I am trying to get full size of a SwiftUI Form which has more content than screen size, that makes it scrollable. Using GeometryReader only gives the screen ...
3
votes
2
answers
1k
views
SwiftUI Binding to a list element only updates values input in the right order
I have an edit view that is presented by a NavigationLink. It takes a recipe, which is held in a manager that has an array of them.
App Code (copy pasta should run):
import SwiftUI
@main
struct ...
0
votes
1
answer
931
views
SwiftUI / iOS / iPhone how to encrypt data/ image before storing and where / how to store locally, general best practice?
I am new to SwiftUI (iOS App Ver 14.x) as I normally use Xamarin.
In this case I need to have the application specifically written in SwiftUI. (I am aware that some stuff still needs UIKit).
I have ...
2
votes
3
answers
797
views
AutoComplete search in swiftui not working
I have a TextField as search box.I want to make it autosearch i.e whenever i will enter a letter in the TextField, i should get the result without press a enter.Here is my code:
TextField("Search&...
2
votes
1
answer
971
views
What do we have as UIButton(Sender: UIButton) in swiftui? [closed]
in the UIKit I catch the button sender (which button is clicked) via code
let colorVC = UIColorPickerViewController()
colorVC.delegate = self
clickedButton = sender
present(...
1
vote
0
answers
477
views
SwiftUI - Material Components , TextFields
I want to use mdc components in my SwiftUI app.
I created a class with protocol UIViewRepresentable, but I would like to modify the height to some constant or maybe remove inner padding.
func ...
0
votes
1
answer
1k
views
How do I send user inputs to a database using the forms feature in swift UI? [closed]
I’m new to swift UI and programming in general. I’ve learnt the basics so far and now I want to be able to setup a simple form in my app. I can design the form no problem. But I’m not sure what ...