swiftui

SwiftUI insertion transion is not working when view added

帅比萌擦擦* 提交于 2021-02-11 13:12:13
问题 I'm trying SwiftUI tutorial in apple developer page. now I'm following transition tutorial but my transition is not working when the view added. here my code. VStack(alignment: .leading) { HStack() { // title Text(titleText) .font(.headline) .padding() Spacer() // button Button(action: { withAnimation { self.showDetail.toggle() } }) { Image(systemName: "chevron.right.circle") .imageScale(.large) .rotationEffect(.degrees(showDetail ? 90 : 0)) .padding() } } // detail if showDetail { Text

How do I make this Picker clip properly

こ雲淡風輕ζ 提交于 2021-02-11 13:09:54
问题 I create a set of side by side pickers in an HStack by calling the view below. The "control" area for each picker is much wider to the left of the picker than it should be. ".clipped()" is supposed to fix this, but it is not working. At some point when I was developing the code, it was working, but now I can't get it back. When I try to manipulate the pickers, I can move the rightmost one anywhere on the right 3 columns. The left column cannot be manipulated at all. What is going on here?

How should I get and set a value of UserDefaults?

落花浮王杯 提交于 2021-02-11 13:00:44
问题 I'm currently developing an application using SwiftUI. I want to use a UserDefaults value in this app. So I made a code below. But in this case, when I reboot the app(the 4'th process in the process below), I can't get value from UserDefaults... Build and Run this project. Pless the home button and the app goes to the background. Double-tap the home button and remove the app screen. press the app icon and reboot the app. Then I want to get value from UserDefaults. to resolve this problem how

How should I get and set a value of UserDefaults?

半腔热情 提交于 2021-02-11 12:59:07
问题 I'm currently developing an application using SwiftUI. I want to use a UserDefaults value in this app. So I made a code below. But in this case, when I reboot the app(the 4'th process in the process below), I can't get value from UserDefaults... Build and Run this project. Pless the home button and the app goes to the background. Double-tap the home button and remove the app screen. press the app icon and reboot the app. Then I want to get value from UserDefaults. to resolve this problem how

StackView layout side by side & on Top of each other (like zStack)

你说的曾经没有我的故事 提交于 2021-02-11 12:50:57
问题 I currently have this interface whereby I am putting a MapView and a UIView on top of each other. The UIView is where I put my chart overlay (eg: Heart Rate). This is fine when the device is in portrait mode. However, I would like to explore a different layout when in landscape mode whereby the UIView(HR Chart) and the MapView is side by side. Is this doable in Interface Builder? Or only in code? (I would like to only use UIKit to better support lower OSes) note : I tried in IB but can't seem

StackView layout side by side & on Top of each other (like zStack)

三世轮回 提交于 2021-02-11 12:50:31
问题 I currently have this interface whereby I am putting a MapView and a UIView on top of each other. The UIView is where I put my chart overlay (eg: Heart Rate). This is fine when the device is in portrait mode. However, I would like to explore a different layout when in landscape mode whereby the UIView(HR Chart) and the MapView is side by side. Is this doable in Interface Builder? Or only in code? (I would like to only use UIKit to better support lower OSes) note : I tried in IB but can't seem

Swift UI Binding TextField in Collection

╄→гoц情女王★ 提交于 2021-02-11 12:31:32
问题 I have two columns with nested data(Parent/child). Each item in first column is parent. When selecting anyone of them then it shows its child in second column as list. When selecting any item from second column then it must show "clipAttr" attribute in third column as text editor where we can edit it. Now I need help how to do that when edit the 'ClipAttr' then it automatically update in SampleDataModel collection. Below is the complete code. struct SampleClip: Identifiable, Hashable { var

Is there any way to call SceneDelegate methods in iOS 14 app life cycle?

天涯浪子 提交于 2021-02-11 12:26:48
问题 We know Apple has drastically simplified the SwiftUI app life cycle (WWDC20). I have seen the video of Mr.Paul Hudson about the new changes in SwiftUI in which he has explained how to access AppDelegate methods in "@main or :App" struct. I want to know if there is any way to access the SceneDelegate methods? Thanks in advance. :) 回答1: There is no access for SceneDelegate now in SwiftUI 2.0 life-cycle. Some of callbacks you can use with .onChange for [.active, .inactive, .background] states as

How to read and filter large Realm dataset in SwiftUI?

▼魔方 西西 提交于 2021-02-11 12:24:47
问题 I'm storing ~100.000 dictionary entries in a realm database and would like to display them. Additionally I want to filter them by a search field. Now I'm running in a problem: The search function is really inefficient although I've tried to debounce the search. View Model: class DictionaryViewModel : ObservableObject { let realm = DatabaseManager.sharedInstance @Published var entries: Results<DictionaryEntry>? @Published var filteredEntries: Results<DictionaryEntry>? @Published var searchText

Complex SwiftUI view performance

被刻印的时光 ゝ 提交于 2021-02-11 12:20:39
问题 I am trying to get the maximum performance out of SwiftUI. I have a complex view and a lot of state and not sure what penalties I am paying as I calculate a lot of views programatically. The view is something like this, stripped to the bare minimum struct ComplexView : View { @State var a = 1 @State var b = 2 // .. more state // Perform function and change some of the state func doIt ( index : Int ) { // ... change some state } // Calculate some view based on state and index func calcView (