LazyVGrid(columns: items, spacing: 2, content: { ForEach(searchingText.isEmpty ? [] : viewModel.filteredPosts(searchingText)) { post in NavigationLink( destination: Postview(viewModel2: PostViewModel(post: post)) .onAppear{ currentListener = Firestore.firestore().collection(posts).document(post.postId).addSnapshotListener { snapshot, err in guard let index = self.viewModel.filteredPosts(searchingText).firstIndex(where: { $0.id == post.id }) else { return } if let doc = try? snapshot?.data(as: Post.self) { self.viewModel.filteredPosts(searchingText)[index].liked = doc.liked } } } ,label: { Text(See likes) }) } }) func filteredPosts(_ query: String) -> [Post] { let lowercasedQuery2 = query.lowercased() return posts.filter({ $0.caption.lowercased().contains(lowercasedQuery2) }) } I am getting : Cannot assign to property: function call returns immutable value error in this part: self.vm2.filteredPosts(searchingText2)[index].liked = doc.liked. Any idea how I can solve it? My goal is to add a snapshot l
Search results for
column
2,071 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Another issue: If --count is set to 1 as result of round: --count: calc(round(down, calc(sqrt(var(--images))), 1) + 1); grid-template-columns: repeat(var(--count), 1fr); grid-template-columns: 1fr; isn’t the same (in Safari)! The first line results in 2 columns, not in one! Looks like the same reason. Because grid-template-columns: repeat(calc(var(--count) -0.01), 1fr); gives one column.
Topic:
Safari & Web
SubTopic:
General
Tags:
I'm working on a calculator app but I'm having trouble displaying the results of a function. When I press a button in ButtonView, a function runs to calculate the result but that result does not display in CalculationCircleView. Main View: struct ScoreCalculatorView: View { @StateObject private var viewModel = ViewModel() var body: some View { VStack { Spacer() HStack { CalculationCircleView(calculation: viewModel.grossScore, label: Score) Spacer() CalculationCircleView(calculation: viewModel.plusMinus, label: +/-) } .padding(.horizontal, 30) Spacer() LazyVGrid(columns: viewModel.columns, spacing: 20) { ForEach(0..<4, id: .self) { index in ZStack { DataCellsView(labels: viewModel.scoreLabels[index]) TextField((viewModel.scoreLabels[index]), text: $viewModel.scoreData[index]) .font(.largeTitle) .fontWeight(.light) .frame(maxWidth: 80) .multilineTextAlignment(.center) .keyboardType(.numberPad) } } } .frame(width: 250) Spacer() ButtonView(data: viewModel.scoreData) .padding(.bottom, 20) } } } Calcula
since 14.3 update I'm missing the type and value column in the Project->Target->%target%->Info view. I only can see the key column. I've already reinstalled Xcode multiple times and restarted my MacBook Pro. Here the screenshot from the new created project: I can add new properties, but I can't change the value. Has anyone some idea, what I can do to fix this problem? Btw: my workmate with similar MacBook Pro setup can change all the values.
I have a csv file with values ranges between 0-1. When converted this csv values to MLMultiArray and then to UIImage it shows grey image. But the image is actually coloured. So is there any step missing or do I have to perform any more action to get this image to be coloured. Sample csv values - [0.556862745 0.62745098 0.811764706] Code func parseCSV(data: String) -> [Float] { var finalArray = [Float]() var rows = data.components(separatedBy: n) for row in rows { let columns = row.components(separatedBy: ,) if columns.count == 3 { let r = columns[0] let g = columns[1] var b = columns[2] if b.contains(r){ b = b.replacingOccurrences(of: r, with: ) } finalArray.append(Float(r)!) finalArray.append(Float(g)!) finalArray.append(Float(b)!) } } return finalArray } let m = try MLMultiArray(shape: [1, 768, 512, 3], dataType: .double) for (index, element) in data.enumerated() { m[index] = NSNumber(value: element) } let model: ModelInput = { do { let config = MLModelConfiguration()
It seems that zstack still has some issues when recalculating multiple layers with lots of views inside it. I consider that overly a floating view on zstack, this view was not calculated by zstack, I copied the code of floating view from here, and the following is the code modified from your version: import SwiftUI struct TMainWnd: View { @State var strings: [String] = [A, B, C, D, E] @State var ints: [Int] = Array(1...300) @State var selectedInt: Int? @State var isShow = false var body: some View { ZStack { ScrollView { VStack { ForEach(strings, id: .self) { string in VStack { HStack { Text(string) Spacer() } LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible())]) { ForEach(ints, id: .self) { int in VStack { Text(String(int)) Spacer() } .frame( maxWidth: .infinity ) .frame(height: 200) .background( RoundedRectangle(cornerRadius: 5) .fill(int % 2 == 0 ? .orange : .green) ) .onTapGesture { self.selectedInt = int } } } } } } .padding() } }.floatingView(above: TFloating
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
ah. thanks for the video, I wasn't scrolling far enough but I couldn't tell where I was. I modified your code so it is easier to see what cell you're at. I couldn't reproduce it with an array of only 30, or even 100 Ints. But with 150 (as below), I can press on C14 and the scroll position will jump so that I'm looking at E14. Your code doesn't modify the scroll position, so this looks like a bug to me. struct ContentView: View { let strings: [String] = [A, B, C, D, E] let ints: [Int] = Array(1...150) @State var selectedCell: String? var body: some View { ZStack { ScrollView { VStack { ForEach(strings, id: .self) { string in VStack { HStack { Text(string) Spacer() } LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible())]) { ForEach(ints, id: .self) { int in VStack { Text(string + String(int)) Spacer() } .frame(minWidth: 0, maxWidth: .infinity) .frame(height: 200) .background( RoundedRectangle(cornerRadius: 5) .fill(int % 2 == 0 ? .orange : .green) ) .onTapGesture { sel
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
Can you share a code example that replicates the issue here? We're tracking similar bugs, but your callout of an explicit stack in the detail column is a configuration we haven't yet seen this issue with.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
Hi everyone, I'm having a hard time figuring out why the code below results in weird behaviour with the ScrollView. Code : struct MainView: View { @State var strings: [String] = [A, B, C, D, E] @State var ints: [Int] = Array(1...300) @State var selectedInt: Int? var body: some View { ZStack { ScrollView { VStack { ForEach(strings, id: .self) { string in VStack { HStack { Text(string) Spacer() } LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible())]) { ForEach(ints, id: .self) { int in VStack { Text(String(int)) Spacer() } .frame(minWidth: 0, maxWidth: .infinity) .frame(height: 200) .background( RoundedRectangle(cornerRadius: 5) .fill(int % 2 == 0 ? .orange : .green) ) .onTapGesture { self.selectedInt = int } } } } } } .padding() } if let selectedInt { VStack { Spacer() Text(String(selectedInt)) Spacer() Button { self.selectedInt = nil } label: { Image(systemName: x.circle) .resizable() .scaledToFit() .frame(width: 30) } } .frame(minWidth: 0, maxWidth: .infinity, minH
I'm using a two column NavigationSplitView, where the view passed for the detail column is the root of a NavigationStack. The navigation works as expected, but the navigationTitle and toolbar elements of the detail view are very slightly delayed when the view appears on iOS, such that they 'pop' in rather than smoothly animating like normal. Returning to the root of the view from views higher in this stack animates as expected. Has anyone seen anything like this before? Thanks!
Hi :-) I´m looking for some help and advice for my little project. Basically I have a Tabview with 3 Tabs. One of them is a View for Favorites. I managed the selection and the saving of the favorites. However, the View for the Favorites is not updating while the app is running. Just when the app is closed and restarted the View of Favorites gets updated. The Array of Favorites is marked with @Published, the variable in the Favorites-View is marked as @ObservedObject. I searched a lot and can't find my mistake. „Expression“ is a Struct with about 10 properties. Class for the Favorites: class Favorites: ObservableObject { @Published var favoriteExpressions: [Expression] = [] { didSet { print(Favorites changed) } } private let saveKey = FavoriteExpressions let defaults = UserDefaults.standard init() { if let data = defaults.data(forKey: saveKey) { let decoder = JSONDecoder() if let decoderSet = try? decoder.decode([Expression].self, from: data) { favoriteExpressions = decoderSet } } } func contains() -> Bool
Hi, the problem is not dangerous to life, I don't want see the yellow button on top of the editor. 'Autoresizing Mask' is set to about 50 items, that works, except tableView, 10 warnings. The tableView has 10 columns of 20 pixels width, min 10 and max 100000. The ' Add new constraints' options are all grayed, so what ? In an other project a warning was set for arrayController, I don't like Auto Layout, the blue help lines are enough. My question is : How do i can suppress this warnings ? Kindly, Uwe
The below code works. I pass in an array of core data entities and display attributes in a table. In the second table column I use a switch case statement to handle the 3 possible attributes I want to display. I could eliminate the switch case if I could figure out how to access a given core data attribute via a variable that contains the specific attribute name but have been unable to determine how to do so. Two attempts are commented out in the code. struct DataTable: View { private var closingValues: Array var heading: String var attribute: String init(closingValues: [TradingDayPrices], heading: String, attribute: String) { self.closingValues = closingValues self.heading = heading self.attribute = attribute } var body: some View { Text(heading) .foregroundColor(.black) .font(Font.custom(Arial, size: 18)) .bold() .padding(.top, 10) Table(self.closingValues) { TableColumn(Date) { value in HStack { Spacer() Text(dateToStringFormatter.string(from: value.timeStamp!)) Spacer() } } .width(100) TableColum
Sorry, I just noticed that the Crashes column was set to Last Year. When I set it to Last Two Weeks, I get the data.
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags:
I'm trying to find the reason for multiple app crashes. App Store Connect shows multiple crashes but the Organizer in Xcode lists a lot of crashes but very few entries have any data. Image is only one of many cases in the organizer. 2nd column from left shows 3 devices but right column shows 0 devices.