swiftui

Hide UINavigationController's navigationBar when the root controller is a UIHostingController

别说谁变了你拦得住时间么 提交于 2021-02-08 09:10:13
问题 I am struggling to hide the navigationBar , which would properly be hidden if the root controller wasn't a SwiftUI UIHostingController . I tried the following: Setting navigationController.isNavigationBarHidden = true after creating it, at viewDidLoad and viewWillAppear . Adding both .navigationBarHidden(true) and .navigationBarBackButtonHidden(true) for the UIHostingController 's rootView . Could it be an Apple bug? I am using Xcode 11.6. All my attempts together: class LoginController:

Hide UINavigationController's navigationBar when the root controller is a UIHostingController

有些话、适合烂在心里 提交于 2021-02-08 09:09:05
问题 I am struggling to hide the navigationBar , which would properly be hidden if the root controller wasn't a SwiftUI UIHostingController . I tried the following: Setting navigationController.isNavigationBarHidden = true after creating it, at viewDidLoad and viewWillAppear . Adding both .navigationBarHidden(true) and .navigationBarBackButtonHidden(true) for the UIHostingController 's rootView . Could it be an Apple bug? I am using Xcode 11.6. All my attempts together: class LoginController:

SwiftUI - Optional Timer, reset and recreate

左心房为你撑大大i 提交于 2021-02-08 08:21:29
问题 Normally, I would use an optional variable to hold my Timer reference, as it's nice to be able to invalidate and set it to nil before recreating. I'm trying to use SwiftUI and want to make sure I'm correctly doing so... I declare as: @State var timer:Publishers.Autoconnect<Timer.TimerPublisher>? = nil Later I: self.timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect() To drive a UI text control I use: .onReceive(timer) { time in print("The time is now \(time)") } What is the

Long press of NavigationView only work on the left part, not all the NavigationLink?

自闭症网瘾萝莉.ら 提交于 2021-02-08 07:37:22
问题 Following is a NavigationView, the view pops to Destination2 when long press the NavigationLink and to Destination1 when normally tap it. But the right zone of the NavigationLink in the picture cannot be long pressed. Does anyone know the reason? Thanks! import SwiftUI struct ContentView: View { @State private var isLongPressed = false @State var currentTag: Int? let lyrics = ["OutNotWorkA", "OutNotWorkB", "OutNotWorkC"] var body: some View { NavigationView { List { ForEach(0..<lyrics.count)

Sharing Screenshot of SwiftUI view causes crash

最后都变了- 提交于 2021-02-08 07:22:56
问题 I am grabbing a screenshot of a sub-view in my SwiftUI View to immediately pass to a share sheet in order to share the image. The view is of a set of questions from a text array rendered as a stack of cards. I am trying to get a screenshot of the question and make it share-able along with a link to the app (testing with a link to angry birds). I have been able to capture the screenshot using basically Asperi's answer to the below question: How do I render a SwiftUI View that is not at the

SwiftUI updating UI with high frequency data

▼魔方 西西 提交于 2021-02-08 06:51:30
问题 I'm trying to update the main view with high frequency data coming from separate background thread. I've created two tabviews and in case of slow update rate I can change the view. But in another case the UI doesn't react. I've observed this behavior only on real device, in the simulator works everything fine. The while loop is still representing an imu, just to keep it simple. Did someone any idea how to fix this issue? Many thanks! import SwiftUI struct ContentView: View {

SwiftUI updating UI with high frequency data

守給你的承諾、 提交于 2021-02-08 06:51:21
问题 I'm trying to update the main view with high frequency data coming from separate background thread. I've created two tabviews and in case of slow update rate I can change the view. But in another case the UI doesn't react. I've observed this behavior only on real device, in the simulator works everything fine. The while loop is still representing an imu, just to keep it simple. Did someone any idea how to fix this issue? Many thanks! import SwiftUI struct ContentView: View {

Text in SwiftUI Form not wrapping after being changed

南笙酒味 提交于 2021-02-08 06:42:02
问题 I need to display some text in a SwiftUI Form that will change depending on the current state. However, if the "new" text is longer than the original string displayed when the form first appeared, it won't wrap correctly. In the example below, turning the toggle on changes the text being displayed, but it gets truncated instead of wrapping struct ContentView: View { @State var showLongString = false var body: some View { Form { Section { Text(showLongString ? "This is a string that is too

Text in SwiftUI Form not wrapping after being changed

放肆的年华 提交于 2021-02-08 06:40:54
问题 I need to display some text in a SwiftUI Form that will change depending on the current state. However, if the "new" text is longer than the original string displayed when the form first appeared, it won't wrap correctly. In the example below, turning the toggle on changes the text being displayed, but it gets truncated instead of wrapping struct ContentView: View { @State var showLongString = false var body: some View { Form { Section { Text(showLongString ? "This is a string that is too

Text in SwiftUI Form not wrapping after being changed

流过昼夜 提交于 2021-02-08 06:40:12
问题 I need to display some text in a SwiftUI Form that will change depending on the current state. However, if the "new" text is longer than the original string displayed when the form first appeared, it won't wrap correctly. In the example below, turning the toggle on changes the text being displayed, but it gets truncated instead of wrapping struct ContentView: View { @State var showLongString = false var body: some View { Form { Section { Text(showLongString ? "This is a string that is too