Post

Replies

Boosts

Views

Activity

Reply to Missing argument for parameter 'images' in call
Sorry if I didn't make this clear, but your code from before should look like this: ForEach(ImagesList, id: \.id) { images in NavigationLink { LandCard() } label: { ImageCard(images: images) } } Currently you are showing the ImageCard view twice, the second as a NavigationLink, but I assume that you only need it once. On your second problem, the height of the ImageCard depends on how you create it. Can you show the code for the ImageCard view so that we can understand what is causing the issue?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to Missing argument for parameter 'images' in call
Missing argument for parameter 'images' in call The problem you have is the ImageCard view has an images parameter that you haven't specified in the NavigationLink label. Consecutive statements on a line must be separated by ';' You also have a closing parenthesis after the NavigationLink which has no matching opening parenthesis; this triggers a syntax error. Replace the contents of your ForEach with this: NavigationLink { LandCard() } label: { ImageCard(images: images) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to SwiftUI sheet accentColor
The accentColor(_:) modifier is marked as being deprecated with a message saying this: Use the asset catalog’s accent color or tint(_:) instead. Using either of these methods will result in a sheet using this accent colour. If you still want to use accentColor(_:), just reapply this modifier to the sheet content, as a workaround.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to Handling single selection action in multi-selection SwiftUI Table
I recently came across a new modifier in macOS Ventura called contextAction(forSelectionType:action:) and seems to do what you are describing. The closure that is run can be used to perform the navigation or whatever you need to happen. I'm currently on Monterey so I don't know how well it works on macOS, but I did try it out on iOS 16. Multi-selection still works when in edit mode, but when edit mode is inactive, tapping on a row performs the closure. Hopefully this helps, and when you try it out on Ventura it works.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to ForEach loop or initializer broken
I have managed to narrow down the issue to the while loop. If it were replaced by a for loop, like this: for _ in 1...20 { numm.append(.random(in: 0...1)) fill += 1 } it would compile and the preview would work. Note: the fill variable is now redundant and won't do anything, unless you use it later on somewhere. After some more debugging, I found that everything in the initialiser has no effect on the two @State variables. You have given them initial values and then tried to change them immediately. Instead, declare them with no value and then set them in the initialiser, like this: @State private var numm: [Int] @State private var fill: Int init() {     _fill = State(initialValue: 0)     var initialNumm: [Int] = []     for _ in 1...20 {         initialNumm.append(.random(in: 0...1))     }     _numm = State(initialValue: initialNumm) } Everything else can be kept the same the way you wrote it.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to Back supported Navigation-View
NavigationView has only been soft deprecated, so will still function on iOS 16. As for manually back deploying, since NavigationView has been split into two parts but come with added components, such as a path and control over column visibility as well as the new NavigationLink(_:value:) and navigationDestination modifier, it would be quite difficult to accomodate all of this.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to Handling a single window app on MacOS with Swift
The first point can easily be solved through the use of a custom class conforming to the NSApplicationDelegate, implemented like this: class AppDelegate: NSObject, NSApplicationDelegate {     func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {         return true     } } and then adding this to the main app file: @NSApplicationDelegateAdaptor private var appDelegate: AppDelegate On your second point, if needed, you can use the new in Ventura Window struct as the main scene of your app, like this: @main struct SingleWindowApp: App { var body: some Scene { Window("SingleWindow", id: "main") { ContentView() } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to SwiftUI slowly adoption
What they actually said during the talk was this: ... if you're new to our platforms or if you're starting a brand-new app, the best way to build an app is with Swift and SwiftUI. Features can be added to existing apps, and Apple is trying to slowly incorporate SwiftUI into UIKit (and other platform-equivalent frameworks), but the orignial statement is aimed at people starting with Swift and learning to build apps with SwiftUI. Companies with apps can still use UIKit (and similar) and incrementally adopt SwiftUI, but don't have to restructure everything, yet.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to navigationTitle with menu
In beta 1, navigationTitle(_:actions:) was how you would set the menu's actions. In beta 2, a new modifier was added for this instead. It was called toolbarTitleActions(actions:). As of beta 3, you will have to use the renamed toolbarTitleMenu(content:) modifier, like this: .toolbarTitleMenu { MyPrintButton() } Note: the menu will only show when the navigation title display mode is .inline.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to Load link from tab bar item
You can detect when the user taps on the specified tab with this: // add to the TabView .onChange(of: selectedTab) { [selectedTab] newTab in if newTab == "OpenLinkTab" { self.selectedTab = selectedTab // return to previously selected tab // open URL here         let url = URL(string: "https://www.apple.com")! openURL(url) } } When the tab item is tapped, it will look like a regular button press as the tab view switches back to the previously selected tab. This is when you can open the link providing the behaviour you want. This solution would be similar to implementing the UITabBarControllerDelegate.tabBarController(_:shouldSelect:) delegate method and returning false (in a UIKit app).
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to Can't change List background color in iOS 16
New in iOS 16 beta 3, two new modifiers! You can use them to set a background colour for a list: List { ... } .scrollContentBackground(Color.red) // using .red results in an error or set a custom background view: List { ... } .scrollContentBackground(.hidden) .background {     Image(systemName: "list.bullet")         .resizable()         .scaledToFit()         .padding() }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to SwiftUI 4: Set list background color
New in iOS 16 beta 3, two new modifiers! You can use them to set a background colour for a list: List { ... } .scrollContentBackground(Color.red) // using .red results in an error or set a custom background view: List { ... } .scrollContentBackground(.hidden) .background {     Image(systemName: "list.bullet")         .resizable()         .scaledToFit()         .padding() }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to Safe Area Insets
I'm assuming you're using SwiftUI since that's what you tagged the question with. If so, your views should automatically be placed to fit in the safe area. Using the ignoresSafeArea(_:edges:) modifier, well, ignores the safe area, so expanding to fill the whole screen. If you want your views to fill the entire space inside of the safe area, you can use a frame modifier like this: .frame(maxWidth: .infinity, maxHeight: .infinity) If you explicitly want the top and bottom safe area inset values, then you can wrap your view in a GeometryReader and access the values like this: GeometryReader { geoProxy in let topInset = geoProxy.safeAreaInsets.top let bottomInset = geoProxy.safeAreaInsets.bottom ... }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to I have problem with this code. I try to append it but i get some error so please help
The variable Produkt is of type Array<ScannProdukt>. In the addRow method, you are appending the value stored in ScannedCode to this array which is of type String. The error comes from the fact that the array expects a value of type ScannProdukt to be appended, but instead got a value of type String. You would need to use the ScannedCode property to create a ScannProdukt that can be appended to the Produkt array.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22