Search results for

swiftui

16,583 results found

Post

Replies

Boosts

Views

Activity

Data from Swift Enum to SwiftUI
I have a class written in Swift that will present the view developed using SwiftUI. SwiftUI is dependent on the enum used in Swift class to render the UI. Is there a way to bind that enum in Swift UI so that SwiftUI will update automatically when ever there is a change to the enum in Swift class
0
0
613
Jul ’21
SwiftUI viewWithTag
Is it possible to find a particular view in SwiftUI based on its tag ?When a row on a List is tapped, I want the textField on a row in another List to be updated.But the problem is I dont know how to get hold of the active textField or the index of the row in the other list.Please refer this image for clarity https://imgur.com/a/Ovv8IBY
1
0
1.1k
Jul ’19
SwiftUI Landmarks tutorial
Hi team, I'm very new to SwiftUI development and have been plugging through the tutorial here - https://developer.apple.com/tutorials/swiftui/building-lists-and-navigation Now I want to try switching from a local JSON file to a remote server JSON response. I've looked over using URLRequest but have been running into various errors. Can someone share how to go about switching the load method from local to remote, in beginner's terms?
1
0
428
Feb ’21
Navigating programmatically in SwiftUI
I followed the official SwiftUI tutorial - https://developer.apple.com/tutorials/swiftui/composing-complex-interfaces to learn how to use SwiftUI. In my app, I want to build login functionality. For that, I have a login screen with a button. On pressing it, a request is sent out and only after receiving the response, I want to navigate to the next screen. The same principle is needed for logging out. After searching the web, the following approach is suggested on many pages, where a state variable is changed by the button action to trigger the empty navigation event. @State var selection: Int? = nil ... Button(Login, action: { viewModel.login(name: username, password: password) { didSucceed in if didSucceed { self.selection = 1 } else { print(Login error, TODO: proper handling) } } }) NavigationLink(destination: MapScreen(), tag: 1, selection: $selection) { EmptyView() } .hidden() Is this the officially recommended way of navigating programmatically in SwiftUI or does a mor
1
0
2.1k
Dec ’20
SwiftUI Refreshing Mechanism
SwiftUI's Refreshing mechanism is driving me crazy. Say that I have this view: NavigationView { List($datasource) { $item in NavigationLink { SubView(item: $item) } label: { Text(item.someAttribute) } } } SubView: TextField(Placeholder, text: $item.someAttribute) And each time I edit the value in the SubView, the SwiftUI's navigation controller retreats the view to the home page(the initial view). Why?
3
0
1.3k
Aug ’22
Metric Crash by Widget SwiftUI
I have the following code. This part of the code is used in the widget var body: some View { VStack(){ Image(uiImage: imageFromUrl(item.icon) ?? defaultImage!)//(onlineImage ?? defaultImage)! .resizable() .frame(width: itemH * 0.70, height: itemH * 0.70) .aspectRatio(contentMode: .fit) Text(item.name) .font(.system(size: titleFont)) .foregroundColor(colorGenerate(0x333333)) .background(Color.clear) .frame(width: imageWH, height: itemH*0.2) .lineLimit(1) .onAppear { } } .frame(width: imageWH, height: itemH) .background(Color.clear) } I really can't find what caused the crash.Or maybe the system killed it directly, but why should it be reported through metrics? The collection of this question is entirely from metrickit There is no problem at the code level, but the following crash occurs on the actual user's phone: Date/Time: 2024-08-08 00:59:09.000 +0800 OS Version: iOS iPhone OS 17.5.1 (21F90) (iPhone OS 17.5.1 (21F90)) Report Version: 104 Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: EXC_BREAKPOI
1
0
487
Aug ’24
SwiftUI navigationTitle
Is there anyway to set/define the colour of the navgationTitle? Have tried 'tint', Text(some title).foregroundColor(.red). Example .navigationTitle(Text(Developer Journal).foregroundColor(Color.white)) Can't seem to influence the Text Color, the old way used to be to use UINavigation and bring that into SwiftUI setting the 'appearance' but figured this would be updated in this release.
0
0
696
Jun ’21
SwiftUI Navigation Link
Hello! I have recently begun using SwiftUI, and I was wondering about how I can change from one screen to another. This is when I learned about Navigation Links. This code I made does not work, and I was wondering what I could do to make it work, and switch views to SelectScreen. (SelectScreen is already a view.) import SwiftUI struct Home: View { var body: some View { NavigationLink{ SelectScreen() } label: { Image(Play) .resizable() .frame(width: 150.0, height: 150.0) } } }
1
0
1.1k
Oct ’23
Opening SwiftUI Settings from AppKit
I have an app that uses AppKit and SwiftUI. The app settings are made with SwiftUI On macOS 13 you could use the following to open SwiftUI settings: NSApp.sendAction(Selector((showSettingsWindow:)), to: nil, from: nil) On macOS 14 Sonoma the above does not work anymore, instead you have to use a SwiftUI View called SettingsLink. Now the problem is, my app needs to open Settings from a part of the app that uses AppKit. My app does not show or use its menubar, so Settings are not accessible from there, so I provide access from a NSMenuItem. How can I programmatically open SwiftUI Settings from AppKit?
3
0
1.1k
Oct ’23