swiftui

How to change view on midnight in WidgetKit, SwiftUI?

白昼怎懂夜的黑 提交于 2021-02-15 04:58:30
问题 I have a code: struct ContentView: View { let entry: LessonWidgetEntry private static let url: URL = URL(string: "widgetUrl")! var body: some View { VStack { switch entry.state { case .none: ProgramNotStartedView() case .currentLesson(let lesson): LessonView(lesson: lesson, imageName: entry.program?.imageName) case .lessonCompleted(let lesson): LessonCompletedView(lesson: lesson) case .programCompleted: ProgramCompletedView() } }.widgetURL(ContentView.url) } } At midnight LessonCompletedView

UITextView - adjust size based on the content in SwiftUI

£可爱£侵袭症+ 提交于 2021-02-14 18:18:32
问题 I am trying to figure out how to make UITextView size dependent on it's contents in SwiftUI. I wrapped the UITextView in UIViewRepresentable as following: struct TextView: UIViewRepresentable { @Binding var showActionSheet: Bool func makeCoordinator() -> Coordinator { Coordinator(self) } func makeUIView(context: Context) -> UITextView { let uiTextView = UITextView() uiTextView.delegate = context.coordinator uiTextView.font = UIFont(name: "HelveticaNeue", size: 15) uiTextView.isScrollEnabled =

How can I get multiple Timers to appropriately animate a Shape in SwiftUI?

家住魔仙堡 提交于 2021-02-11 18:24:42
问题 Apologies in advance for any tacky code (I'm still learning Swift and SwiftUI). I have a project where I'd like to have multiple timers in an Array count down to zero, one at a time. When the user clicks start, the first timer in the Array counts down and finishes, and a completion handler is called which shifts the array to the left with removeFirst() and starts the next timer (now the first timer in the list) and does this until all timers are done. I also have a custom Shape called

How can I get multiple Timers to appropriately animate a Shape in SwiftUI?

*爱你&永不变心* 提交于 2021-02-11 18:24:13
问题 Apologies in advance for any tacky code (I'm still learning Swift and SwiftUI). I have a project where I'd like to have multiple timers in an Array count down to zero, one at a time. When the user clicks start, the first timer in the Array counts down and finishes, and a completion handler is called which shifts the array to the left with removeFirst() and starts the next timer (now the first timer in the list) and does this until all timers are done. I also have a custom Shape called

Removing large amounts of whitespace in a SwiftUI subview

ぐ巨炮叔叔 提交于 2021-02-11 18:16:04
问题 Demonstration of whitespace problem When I nest a NavigationView within a NavigationView, an enormous amount of whitespace separates the back button and the new navigation bar title. Is there something I'm doing wrong in terms of setting up my SwiftUI views? import SwiftUI struct Dashboard: View { @EnvironmentObject var user: User let courses = Course.exampleCourses() var body: some View { NavigationView { List(courses) { course in NavigationLink(destination: CourseView(course: course)) {

Removing large amounts of whitespace in a SwiftUI subview

你离开我真会死。 提交于 2021-02-11 18:15:52
问题 Demonstration of whitespace problem When I nest a NavigationView within a NavigationView, an enormous amount of whitespace separates the back button and the new navigation bar title. Is there something I'm doing wrong in terms of setting up my SwiftUI views? import SwiftUI struct Dashboard: View { @EnvironmentObject var user: User let courses = Course.exampleCourses() var body: some View { NavigationView { List(courses) { course in NavigationLink(destination: CourseView(course: course)) {

Selecting a picker value to lead to a text field, SwiftUI

耗尽温柔 提交于 2021-02-11 17:55:20
问题 Im trying to implement a feature in my app. When I click on my picker: Picker(selection: $profileViewModel.education, label: Text("Education Level")) { ForEach(Education.levels, id: \.self) { level in Text(level).tag(level) } } This takes me to a screen and then I select the value (this is fine - it works as expected) How could I select the value which then takes my to let's say another screen so I can fill in more details regarding the selected value. For example the above picker has a

IOS swiftUI can't read json from local files [closed]

依然范特西╮ 提交于 2021-02-11 17:51:35
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 10 months ago . Improve this question I'm new with IOS development, I'm using swiftUI and following this tutorial https://developer.apple.com/tutorials/swiftui/building-lists-and-navigation but I have been stuck here for a while, In the tutorial, they pass one item from a json file in the project struct

IOS swiftUI can't read json from local files [closed]

淺唱寂寞╮ 提交于 2021-02-11 17:51:07
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 10 months ago . Improve this question I'm new with IOS development, I'm using swiftUI and following this tutorial https://developer.apple.com/tutorials/swiftui/building-lists-and-navigation but I have been stuck here for a while, In the tutorial, they pass one item from a json file in the project struct

In iOS 13.4, SwiftUI ObservedObject in nested ForEach no longer updates View as in iOS 13.3 [duplicate]

﹥>﹥吖頭↗ 提交于 2021-02-11 17:42:18
问题 This question already has answers here : SwiftUI ForEach based on State int (2 answers) Closed 11 months ago . Here is a simple code to show the problem. It displays a list of name in OberservedObject data , which is in nested ForEach. When data is updated by clicking the button, the view should be updated. The code works perfectly in iOS 13.3 for both simulators and devices, i.e. the view will be updated after clicking the button. But it fails in iOS 13.4 for both simulators and devices, i.e