Difference between SceneDelegate and AppDelegate

In my SwiftUI project I see AppDelegate file as well as a SceneDelegate file. What are the differences between them? For example between the methods in...

How to show or hide an overlay at a Text or Button

I do have a few items that I need to hide ( not disable ) or show depending on a value. As for a Text() or BUtton() sample, I need to have a overlay or no overlay. Button("how secret?",...

Get index in ForEach in SwiftUI

I have an array and I want to iterate through it initialize views based on array value, and want to perform action based on array item index When I iterate through objects ForEach(array, id:...

SwiftUI: How to pop to Root view

Finally now with Beta 5 we can programmatically pop to a parent View. However, there are several places in my App where a View has a "Save" button that concludes a several step process and returns...

How to make hyperlinks in SwiftUI

In Swift, as shown here, you can use "NSMutableAttributedString" to embed links in text. How can I achieve this with SwiftUI? I implemented it as follows, but that does not look how I want it to....

Changing the color of a Button in SwiftUI on tvOS

I am trying to change the color of a SwiftUI Button on tvOS. Modifying the background almost works, except that you can see that the underlying UIButton is actually using a rounded, translucent...

Remove circular button background in SwiftUI (WatchKit)

I'm struggling to remove the background of a custom circular Button element in SwiftUI which is defined as follows: struct NavButton: View { var body: some View { Button(action: {}) ...

Is there a way to hide scroll indicators in a SwiftUI List?

I want to create a SwiftUI List, but not show scroll indicators. ScrollView offers showsIndicators to do this. How can it be done?

UIHostingController should expand to fit contents

I have a custom UIViewControllerRepresentable (layout-related code shown below). This tries to replicate the native SwiftUI ScrollView, except it scrolls from the bottom except the top. View...

Google place autocomplete API with SwiftUI

I am trying to implement auto search for address in my App using SwiftUI. Google tutorial are based on UIKit, I was hoping if someone has tried and can guide me to the right direction. Thanks

SwiftUI - How to create TextField that only accepts numbers

I'm new to SwiftUI and iOS, and I'm trying to create an input field that will only accept numbers. TextField("Total number of people", text: $numOfPeople) The TextField currently allows...

SwiftUI - how know number of lines in Text?

I have a dynamic text, it can be small or large I what by default show only 3 lines and only if needed add "more" button. When the user tap on this button ("More") - I will show all test. I ask,...

SwiftUI GeometryReader does not layout custom subviews in center

I have a custom view: struct ImageContent: View { var body: some View { Image("smile") .resizable() .scaledToFit() } } Which is being placed into another...

Rotate a Text view and its frame in SwiftUI

I can rotate the Text in SwiftUI using rotationEffect but it doesn't rotate the frame. As shown in the image, the text is rotated but the frame is still horizontal. I would like to rotate the...

SwiftUI / Xcode Error - Updating took more than 5 seconds

When I try to preview one of my views in the canvas I keep getting the following error: PreviewUpdateTimedOutError: Updating took more than 5 seconds All my other views load perfectly fine. Why...

How to make a button draggable/movable with SwiftUI?

I am trying to make a Button Movable with SwiftUI. From what it looks like this should work. I have tried putting the Button with Text inside another ZStack and for a second it was working but as...

SwiftUI on macOS, how to use custom image symbol on Button?

READ THE QUESTION CAREFULLY, THIS IS A MAC APP, systemName is not available on mac os I'm trying to build a simple application using swiftUI on macOS, however I'm having some trouble displaying...

What is the lifecycle of @State variables in SwiftUI?

If I create a new @State variable, when does it get destroyed? Does it live for the lifetime of the parent UIHostingController? As far as I can find, it is not documented. This is relevant because...

SwiftUI Date formatting

i take this from Github: https://github.com/emilioschepis/techfeed When i start the app, i getting a issue in the console: Could not convert "Wed, 03 Aug 2011 09:44:00 +0200" to Date. and i have a...

SwiftUI Picker view without label

EDIT: I tried using the WheelPickerStyle outside of the form, however what I want is the same idea, the actual options instead of the label, but as a list. Just like in my example with the Form,...

Result of 'View' initializer is unused

My Custom button does not tap and passes to next view called AddCreditCardView. I have tested the button action with print statement and it won't work too. I copied my code below in separate. This...

SwiftUI onDrag. How to provide multiple NSItemProviders?

In SwiftUI on MacOs, when implementing onDrop(of supportedTypes: [String], isTargeted: Binding<Bool>?, perform action: @escaping ([NSItemProvider]) -> Bool) -> some View we receive an array of...

SwiftUI Align one text centre and one trailing

I am trying to add some detail to a custom chart view that I have made. I currently have the chart and the title in a VStack. This is working perfectly and means the title is centred above the...

SwiftUI: Full screen View over NavigationBar and TabBar

I'm trying to add a full screen View over my app in SwiftUI. The purpose of this is to have a "shade" that fades in that will darken the screen and bring focus to a custom pop-up, disabling...

SwiftUI NavigationLink for iOS 14.5 not working

I had the following code in Xcode 12.4 that worked perfectly ScrollView(.horizontal, showsIndicators: false) { LazyHGrid(rows: rows, spacing: 0) { HStack { if (type ==...

SwiftUI Unexpectedly NavigationLink pops automatically

I have a simple use case where a screen pushes another screen using the NavigationLink. There is a strange behaviour iOS 14.5 where the pushed screen is popped just after being...

How to take just the current time (hh:mm:ss format) from Date() in Swift?

var currentDT = Date() print(currentDT) This prints more information than I need right now. How can I just take time (hh:mm:ss) or date (dd-mm-yy) from this? This feels like a stupid question....

How can an Xcode crash report say a function recursively calls itself, when the code has no recursion?

Our app crashed, and this is the top of the stack trace: Thread 0 name: Thread 0 Crashed: 0 MyApp 0x00000001029ddb44 Swift runtime failure: Index out of range + 0...

iOS swiftUI app warning RSABSSATokenBlinder is implemented in two locations

objc[68450]: Class RSABSSATokenBlinder is implemented in both...

Swift iOS adapt font size to frame

I am trying to adapt the font size of a text element whose length varies greatly so that it fills the whole frame where it is located and no word needs to be truncated (in a iOS app). In the...

Relevant tags