swiftui-list

How to remove the default Navigation Bar space in SwiftUI NavigiationView

拈花ヽ惹草 提交于 2019-12-04 02:07:22
I am new to SwiftUI (like most people) and trying to figure out how to remove some whitespace above a List that I embedded in a NavigationView In this image, you can see that there is some white space above the List What I want to accomplish is this I've tried using .navigationBarHidden(true) but this did not make any noticeable changes. i'm currently setting up my navigiationView like this NavigationView { FileBrowserView(jsonFromCall: URLRetrieve(URLtoFetch: applicationDelegate.apiURL)) .navigationBarHidden(true) } where FileBrowserView is a view with a List and Cells defined like this List

How to bind an array and List if the array is a member of ObservableObject?

こ雲淡風輕ζ 提交于 2019-12-02 11:06:18
I want to create MyViewModel which gets data from network and then updates the arrray of results. MyView should subscribe to the $model.results and show List filled with the results. Unfortunately I get an error about "Type of expression is ambiguous without more context". How to properly use ForEach for this case? import SwiftUI import Combine class MyViewModel: ObservableObject { @Published var results: [String] = [] init() { DispatchQueue.main.asyncAfter(deadline: .now() + 1) { self.results = ["Hello", "World", "!!!"] } } } struct MyView: View { @ObservedObject var model: MyViewModel var