swift5

Trying to make a wrapper for a property that should adjust a string

我的未来我决定 提交于 2020-02-05 06:08:06
问题 I have this code that I need to make reusable by other apps. This code shows messages where the localized app's name is present. So, I have localized strings like this: "DoYou" = "Do you really want to close $$$?"; "Quit" = "Quit $$$"; "Keep Running" = "Keep $$$ Running"; Where $$$ must be replaced with the localized app's name at run time. Because I want to learn about property wrappers, I have tried to create this one: extension String { func findReplace(_ target: String, withString: String

SwiftUI add subview dynamically but the animation doesn't work

孤人 提交于 2020-02-04 06:39:22
问题 I would like to create a view in SwiftUI that add a subview dynamically and with animation. struct ContentView : View { @State private var isButtonVisible = false var body: some View { VStack { Toggle(isOn: $isButtonVisible.animation()) { Text("add view button") } if isButtonVisible { AnyView(DetailView()) .transition(.move(edge: .trailing)) .animation(Animation.linear(duration: 2)) }else{ AnyView(Text("test")) } } } } The above code works fine with the animation . however when i move the

Unable to simultaneously satisfy constraints error whats causing this?

时光毁灭记忆、已成空白 提交于 2020-01-30 11:53:28
问题 ca someone help me with this import UIKit import Firebase class aboutmeViewController: UIViewController , UITableViewDelegate,UITableViewDataSource { var refrelation : DatabaseReference! @IBOutlet weak var me: UITableView! var relationList = [aboutmeModel] () public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return relationList.count } public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell =

AudioKit: AKMidiInstrument crashes on init after upgrading to xcode 11

六月ゝ 毕业季﹏ 提交于 2020-01-25 08:32:05
问题 Crash happens even on demo project SequencerDemo . the line: var bassDrum = AKSynthKick() gets: Thread 1: EXC_BAD_ACCESS (code=1, address=0x0) Happens with every instance of AKMidiInstrument 来源: https://stackoverflow.com/questions/58521803/audiokit-akmidiinstrument-crashes-on-init-after-upgrading-to-xcode-11

Alamofire Request call with: Parameters, Headers and Body not working

依然范特西╮ 提交于 2020-01-25 06:57:27
问题 I have two questions with regards to the Alamofire code below. My JSON fails if I remove the ?action=heartbeat at the end of the URL even though I have action = heartbeat in the parameters, why? How do I add my JSON data/body in the AF.request code below? let urlString = "https://intelipos.dynalias.net/ioc/rest.asp?action=heartbeat" let parameters = ["action":"heartbeat"] let headers: HTTPHeaders = ["Content-Type":"application/json"] AF.request(urlString, method: .post, parameters: parameters

SwiftUI: List Refresh scrolls up

为君一笑 提交于 2020-01-25 06:41:12
问题 I just discovered a funny behavior. if .id(UUID().uuidString) modifier of the List is commented, when a user modifies the value of a bound control which is not visible at the initial view (which means the control may be at somewhere towards the end of the list), the list will scroll up as the bound value will refresh the view. However, if .id(UUID().uuidString) the modifier is commented out, the list won't scroll up, it will stay as where it is - which is good for me. I am just curious if

SwiftUI: How do I loop through an array of Int inside “For Each”

允我心安 提交于 2020-01-24 19:25:53
问题 I am getting the following error "Closure containing control flow statement cannot be used with function builder 'ViewBuilder'" Not able to find similar troubleshoot anywhere. struct FavoriteView: View { @EnvironmentObject var userData: UserData @State var isfavorite = false var favoriteindex = [1,2,3] var body: some View { NavigationView { List { ForEach(userData.labvaluesUserdata) {section in for numbers in favoriteindex { if section.id == (numbers) { ItemRow(list: section) } } } } } } }

SwiftUI: How do I loop through an array of Int inside “For Each”

跟風遠走 提交于 2020-01-24 19:24:05
问题 I am getting the following error "Closure containing control flow statement cannot be used with function builder 'ViewBuilder'" Not able to find similar troubleshoot anywhere. struct FavoriteView: View { @EnvironmentObject var userData: UserData @State var isfavorite = false var favoriteindex = [1,2,3] var body: some View { NavigationView { List { ForEach(userData.labvaluesUserdata) {section in for numbers in favoriteindex { if section.id == (numbers) { ItemRow(list: section) } } } } } } }

Determine if image in table view cell is completely visible

不羁岁月 提交于 2020-01-24 09:39:07
问题 I have a table view where each table view cell has an image. I need to determine when an image view is completely visible on scroll. Additionally, if two images in two separate table view cells are completely visible at the same time, I want to only trigger an action for the first image. I've thought of using willDisplay, but I've found that this only ever triggers once and it triggers as soon as the cell comes into view. I also found this question, but it's specific to determining if the

How do I transition from a login view to a tabView in SwiftUI

孤街浪徒 提交于 2020-01-24 01:17:05
问题 I have a Google Sign-in screen, and then it should transition to a TabView. I tried using a ZStack, but it's causing the app to glitch before each tab is loaded. It will show the sign-in button for a second, and then the correct tab will appear. Is there a way to totally segue similar to ViewControllers? Or is there a way to totally remove the sign-in button before I call the new view (MainView)? MainView is just a SwiftUI view with a tabView, and tabItems. I have a SwiftUI SignInView: import