swiftui-bug

SwiftUI Toggle in a VStack is misaligned

陌路散爱 提交于 2020-04-30 10:31:09
问题 I have a simple List where each row is a Toggle with its Text and Text as a subtitle all in a VStack . All works fine until I start showing or hiding some rows. Somehow the switch of the Toggle view is misaligned and is placed over its title. This happens only on the device and not when running on the simulator. It happens with both XCode 13.3 and 13.4 beta on a device running iOS 13.3.1 The complete example is import SwiftUI struct ContentView: View { @State var showDetails = false @State

onDisappear not called when a modal View is dismissed

假如想象 提交于 2020-04-16 02:26:13
问题 I rely on the SwiftUI's .onDisappear to perform some logic but it is not being called when the user dismisses a modally presented view with the swipe gesture. To reproduce Present a view modally a "ChildView 1" On this view, push a "ChildView 2" as a navigation child Swipe down to dismiss the modal view. The .onDisappear of "ChildView 2" is not called. Sample code to reproduce import SwiftUI struct ContentView: View { @State var isShowingModal var body: some View { NavigationView { Button

ObervableObject being init multiple time, and not refreshing my view

安稳与你 提交于 2020-03-04 23:08:13
问题 i have a structure like that contentView { navigationView{ foreach { NavigationLink(ViewA(id: id)) } } } ///where View A contain an request trigger in view Appear struct ViewA: View { @State var filterString: String = "" var id: String! @ObservedObject var model: ListObj = ListObj() init(id: String) { self.id = id } var body: some View { VStack { SearchBarView(searchText: $filterString) List { ForEach(model.items.filter({ filterString.isEmpty || $0.id.contains(filterString) || $0.name

Multiple Alerts in one view can not be called SwiftUI

混江龙づ霸主 提交于 2020-01-24 00:25:28
问题 The method of calling an alert in swiftUI is supposed to be simpler than ever, a simple example of this would be struct ContentView: View { @State private var showingAlert = false var body: some View { Button(action: { self.showingAlert = true }) { Text("Show Alert") } .alert(isPresented: $showingAlert) { Alert(title: Text("Important message"), message: Text("Wear sunscreen"), dismissButton: .default(Text("Got it!"))) } } } However, even though I am calling an alert and can verify the method

How to remove the default Navigation Bar space in SwiftUI NavigiationView

我的未来我决定 提交于 2019-12-29 18:42:14
问题 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))