Search results for

column

2,071 results found

Post

Replies

Boosts

Views

Activity

Reply to Build Simulator crash
The code is very long so i hope this edit is sufficient to read. Where do you use relativeRiskPickerIndex31? - there are 31 questions in this part of the app,. each app has 2 sets of answers for users to choose from. #1 Slope Angle (they choose answer from picker one) and picker two in the relativeRiskPickerIndex.. basically there are from 1 until 31 risk picker indexes using this: let relativeRiskChoices = [Select, Negligible, Minor, Moderate, Significant, Major] let relativeRiskScores = [-,A, B, C, D, E] //the code above this line is from another swift file that just gets called to the file to the code below. The state var values are all zero. There is no error message inside the code lines but when I run the simulator and try to run and pick answers from the questions and answers inside the simulator, it Freezes and stops working. so i have to force quit it again to try to run it again. however, if i do not use the pickers and just directly try to export pdf, it works. The last time I tried this popped up
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’23
Issue inserting row in TabularData's DataFrame
I'm fairly new to Swift programming so I might be overlooking something, but I'm puzzled why the following code doesn't properly insert a row in a DataFrame. The goal is to move a row at a given index to a new index. I would normally: Copy the row that I want to move Remove the row from the original dataset Insert the copy to the new position The CSV I'm using is from Wikipedia: Year,Make,Model,Description,Price 1997,Ford,E350,ac, abs, moon,3000.00 1999,Chevy,Venture Extended Edition,,4900.00 1999,Chevy,Venture Extended Edition, Very Large,,5000.00 1996,Jeep,Grand Cherokee,MUST SELL! air, moon roof, loaded,4799.00 My code (Swift playground): import Foundation import TabularData let fileUrl = Bundle.main.url(forResource: data, withExtension: csv) let options = CSVReadingOptions(hasHeaderRow: true, delimiter: ,) var dataFrame = try! DataFrame(contentsOfCSVFile: fileUrl!, options: options) print(Original data) print(dataFrame) let rowToMove: Int = 2 let row = dataFrame.rows[rowToMove] print(Row to move) print(ro
4
0
1.1k
Jul ’23
FileManager Has Saved My Images - yet I cannot see / display them whenever I close and reopen the application.
So basically I can tell that the images are being saved by the system (it shows it on the debug terminal) however whenever I close, and then reopen the app the images firstly aren't there at all but also whenever I search the address name I saved them as... I have tried diagonsing the problem by changing UUID's, changing PNGs to JPGS - no matter what I do it does not show once the application has closed. I think it might have to do with how the image are .HEIF (apple's standard) but I don't have any concrete evidence to back this up. If anyone can help it would be greatly apperciated. import SwiftUI import MapKit import CoreLocation struct ContentView: View { @StateObject private var mapAPI = MapAPI() @State private var text = @State private var locationInfo: String = @State private var showLocationInfo = false @State private var imageUrls = [String]() // Array to store image URLs @State private var showImagePicker = false @State private var showCamera = false @State private var selectedImage: UIImage? @Sta
1
0
722
Jul ’23
FileManager Has Saved My Images - yet I cannot see / display them whenever I close and reopen the application.
So basically I can tell that the images are being saved by the system (it shows it on the debug terminal) however whenever I close, and then reopen the app the images firstly aren't there at all but also whenever I search the address name I saved them as... I have tried diagonsing the problem by changing UUID's, changing PNGs to JPGS - no matter what I do it does not show once the application has closed. I think it might have to do with how the image are .HEIF (apple's standard) but I don't have any concrete evidence to back this up. If anyone can help it would be greatly apperciated. import SwiftUI import MapKit import CoreLocation struct ContentView: View { @StateObject private var mapAPI = MapAPI() @State private var text = @State private var locationInfo: String = @State private var showLocationInfo = false @State private var imageUrls = [String]() // Array to store image URLs @State private var showImagePicker = false @State private var showCamera = false @State private var selectedImage: UIImage? @Sta
2
0
699
Jul ’23
Alert within Popover is clipped in height causing title to be hidden
When showing an Alert from within a Popover that has a fixed height, the newly presented Alert is in the same position but gets limited by the Popovers height causing the title of the Alert to be hidden. Is this intentional behavior or are Alerts not supported within Popovers and I'd have to pass it through to my main view? Code: // // DemoalertPopover.swift // ******** // // Created by Thilo on 26.06.2023. // import SwiftUI struct DemoAlertPopover: View { @Environment(.dismiss) var dismiss @State private var showDeleteConfirmation = false let dateFormatter: DateFormatter = { let formatter = DateFormatter() formatter.dateFormat = dd.MM.yyyy return formatter }() var body: some View { VStack(alignment: .leading, spacing: 0) { HStack { Text(Title).font(.extraLargeTitle).lineLimit(1) Spacer() Button(action: { dismiss() }) { Label(Close, systemImage: xmark).labelStyle(.iconOnly) } } HStack(alignment: .center) { Text(Content).font(.largeTitle) Text(Content2).foregroundStyle(.secondary) } LazyVGrid(columns:
2
0
846
Jun ’23
How to hide stacked navigation bars when using SwiftUI inspector in UISplitViewController secondary column
During WWDC Q&As I asked how I could add an inspector to my UIKit app that’s using UISplitViewController with a double column style featuring a sidebar and detail view controller. I initially tried a full-height inspector (by putting my split view controller into a SwiftUI view and applying the inspector on that, embedding that into a UIHostingController to be the rootViewController) but this caused a bunch of UI bugs (seemingly related to optimizations made for a size class that doesn’t match the actual appearance) and it doesn’t extend into the NSToolbar on Mac Catalyst anyways. I now want to try implementing the under-the-toolbar solution. An engineer said: For an under toolbar appearance, you should be able to use .inspector on the detail view controller (after wrapping it in a SwiftUI view), but you may have to do manual toolbar management here (hiding and showing) to make sure you don't end up with stacked toolbars/UINavigationBars I have indeed run into the problem with two navigation bars
0
0
1.2k
Jun ’23
This is my code for a Personal Project - the problem I'm facing is saving the images that the user has added - i run into to problem after problem so if anyone can help in saving the images under the encoded address so I can access that would be good
struct ImagePicker: UIViewControllerRepresentable { typealias UIViewControllerType = UIImagePickerController var sourceType: UIImagePickerController.SourceType var completionHandler: (UIImage?) -> Void func makeUIViewController(context: Context) -> UIImagePickerController { let imagePicker = UIImagePickerController() imagePicker.sourceType = sourceType imagePicker.delegate = context.coordinator return imagePicker } func updateUIViewController(_ uiViewController: UIImagePickerController, context: Context) { // No update needed } func makeCoordinator() -> Coordinator { Coordinator(completionHandler: completionHandler) } final class Coordinator: NSObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate { private let completionHandler: (UIImage?) -> Void init(completionHandler: @escaping (UIImage?) -> Void) { self.completionHandler = completionHandler } func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey
0
0
564
Jun ’23
Full height SwiftUI inspector in Mac Catalyst app
I have a UIKit Mac Catalyst app, optimized for Mac idiom, with an NSToolbar manually added to the windowScene. Is it possible to implement a full-height inspector sidebar with this setup? It seems to always appear underneath the toolbar in my testing. Even if I remove my NSToolbar and let the system create a toolbar from a NavigationStack. It works on iOS - stretches all the way up the window splitting the app into two columns. var body: some View { NavigationStack { AnimalTable(state: $state) .inspector(isPresented: $state.inspectorPresented) { AnimalInspectorForm(animal: $state.binding()) } .toolbar { Button { state.inspectorPresented.toggle() } label: { Label(Toggle Inspector, systemImage: info.circle) } } } }
0
0
1k
Jun ’23
How do I disable a button while it has focus
I have a view that shows a table and 4 buttons. Each button allows the user to step forward and backwards through the data. Buttons are enabled and disabled based on where you are in the data. If you are less than 200 values to the end of the data for example, the Page Down - 200 button is disabled. Everything works fine if the mouse is used to run the code associated with each button. But in this case I think the buttons never get focus. Focus I think remains with the sidebar content item that brought up the table view (am using a navigation split view). If I tab over to the page down 200 button and use the space bar to run its associated code I get the error AttributeGraph: cycle detected through attribute 864480. I think the problem lies with attempting to disable the button while it has focus but am not 100% sure. I have tried to change the focus prior to disabling the button but I get the same error. I think there is some fundamental that I am missing. Below is my table view along with the page down 200
3
0
1.6k
Jun ’23
No audio on device speakers, works fine with headphones / airplay
hi I am having a issue with sound on a network video stream, the stream is loaded by a m3u,. during playback there is no audio from the device, however when using headphones / airplay audio works correctly. the other peculiar thing is the device simulator works fine. this maybe related to airplay working, but I don't know. this is the view handling the playback. Im not sure where the issue is. I can also play the videos fine when embedding the avplayer in its own view. but that looks messy when you have to dismiss a second window when closing the video. #if os(iOS) import SwiftUI import AVKit import MediaPlayer struct iOSVideoLibraryView: View { @ObservedObject var videoLibrary: VideoLibrary @State private var isPlayerDismissed = false let LiveStreams = [GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible())] let VODStreams = [GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible())] var body: some View { NavigationView { ScrollView { LazyVGrid(columns:
2
0
1.3k
Jun ’23
String Catalogs won't import translated .xliff
We use a localization service that allows us to export our translated strings in .xliff format. When I import the spanish (es.xliff) file into the string catalogs it imports the english keys and leaves the spanish translation column empty, which causes it to default to English. I created feedback 12429535 and 12429469 because it seems the feedback site is broken and shows it cannot find the feedback I just submitted.
0
0
906
Jun ’23
Reply to Instruments: what is static AppName.$main() [inlined]
I submitted FB12211784 the end of May. It contains a do-nothing-much app that creates a two column table of 10K entries. Selecting an item in the table causes the color of the text in the first column to change. On my 2019 intel iMac there is about a 140 msec delay between selection and the color change. That is noticeable. I just re-ran the code using a brand new Mac Studio with M2 Max. It still takes over 100 msec. Still noticeable.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’23
This is my code - the problem is that I made most of the app so far using the iPhone 14 Pro Max and it has the sizing of that phone so can you please help change it so that it will fit any phone no matter size. This is most of the code.
// Page 1: Map Search VStack { ZStack(alignment: .topLeading) { Map(coordinateRegion: $mapAPI.region, annotationItems: mapAPI.locations) { location in MapMarker(coordinate: location.coordinate, tint: .red) } .ignoresSafeArea() VStack { HStack { TextField(Enter an address, text: $text) .textFieldStyle(.roundedBorder) .padding(.horizontal) .foregroundColor(.black) Button(action: { fetchLocationInfoFromWikipedia(for: text) mapAPI.getLocation(address: text, delta: 0.5) showLocationInfo = true }) { Image(systemName: magnifyingglass) .foregroundColor(.black) } .padding(.leading, -50) } .padding() if showLocationInfo { VStack { Spacer() Rectangle() .fill(Color.white) .frame(height: 250) .frame(width: 400) .cornerRadius(15) .overlay( ScrollView { Text(locationInfo) .foregroundColor(.black) .padding(.horizontal, 10) .font(.system(size: 14)) .font(.custom(Serif, fixedSize: 14)) } .padding() ) .padding(.horizontal, 20) .padding(.bottom, 10) // Adjust the bottom padding here HStack(spacing: 70) { Button(action: { // Open
2
0
646
Jun ’23
Reply to How do I initialize a view models variables in a view
I moved the on appear to the h stack but the table rows portion of the table still ran before the on appear resulting in an index out of range error. So I added the suggested state variable and if statement. The view now works perfectly. Thank you again for providing great advice. Below is the updated code. struct DataTable: View { @ObservedObject var vm: ButtonsViewModel = ButtonsViewModel.shared var closingValues: [TradingDayClose] var heading: String = @State private var hasAppeared = false init(fundName: String, closingValues: [TradingDayClose]) { self.heading = fundName self.closingValues = closingValues } var body: some View { HStack { Spacer() .frame(width: 150) GroupBox(heading) { if hasAppeared { Table (of: TradingDayClose.self) { TableColumn() { closingValue in Text(dateToStringFormatter.string(from: closingValue.timeStamp!)) .id(closingValue.timeStamp!) .textFormatting(fontSize: 14) .frame(width: 100, alignment: .center) } // end table column TableColumn() { closingValue in Text(String(fo
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’23
SwiftUI dropDestination location in a grid
I've put together a simplified code example to test how the location of dropDestination works within a Grid View. When I attach dropDestination to Grid, GridRow or the Text((row) , (column)) view, I get a CGPoint corresponding to the drop location within the views coordinate space. But the problem is how would I get the either the index of a grid cell eg. (1, 1) or the grid cell view itself? Apple's documentation regarding drag and drop in SwiftUI says to prefer using transferable items which I interpret as them recommending dropDestination over the older onDrop with an NSItemProvider. But unlike in a List view there doesn't seem to be away for location to return discrete values. If I instead attach dropDestination to a one of the nested ForEach loops within the Grid view, the drop gesture doesn't do anything? Also dropDestination exhibits some default behaviour that I don't want. When dragging a view a little plus symbol within a green circle appears Views can be dragged and dropped out of the apps
1
0
1.8k
Jun ’23