What's new in SwiftUI

RSS for tag

Discuss the WWDC21 session What's new in SwiftUI.

View Session

Posts under wwdc21-10018 tag

46 Posts
Sort by:
Post not yet marked as solved
1 Replies
109 Views
//MARK : HealthStore   func getData() -> Double {     //Get Authorization     let stepType = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.stepCount)!     let heartRate = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.heartRate)!     let spo2 = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.respiratoryRate)!     healthStore.requestAuthorization(toShare: [], read: [stepType,heartRate,spo2]) { (chk, error) in       if (chk){         print("Permission Granted")                   var dumm = 0.0         //currentHeartRate(completion: nil)         self.getSteps(currentDate: Date()) { result in           globalString.todayStepsCount = result           dumm = result           print(result)         }         return dumm       }                    }         } //getData             func getSteps(currentDate: Date, completion: @escaping (Double) -> Void) {     guard let sampleType = HKCategoryType.quantityType(forIdentifier: .stepCount) else {       print("Get Steps not executed as is null")       return     }     let now = currentDate //Date()     let startDate = Calendar.current.startOfDay(for: now)     let predicate = HKQuery.predicateForSamples(withStart: startDate, end: now, options: .strictEndDate)     let query = HKStatisticsQuery(quantityType: sampleType, quantitySamplePredicate: predicate, options: .cumulativeSum)     { _, result, _ in         guard let result = result, let sum = result.sumQuantity() else {           completion(0.0)           return         }         completion(sum.doubleValue(for: HKUnit.count()))       }     healthStore.execute(query)   }
Posted
by
Post not yet marked as solved
1 Replies
164 Views
I am working through the "Creating and Combining Views" Swift UI Landmarks tutorial using MacOS 12.3 and XCode 13.3. When trying to preview the MapView I receive the error: |  LoadingError: failed to load library at path "/Users/Elizabeth_Russell/Library/Developer/Xcode/DerivedData/Landmarks-fifnagwlpuhontdywqyzptoyghbg/Build/Intermediates.noindex/Previews/Landmarks/Intermediates.noindex/Landmarks.build/Debug-iphonesimulator/Landmarks.build/Objects-normal/arm64/MapView.1.preview-thunk.dylib": Optional(dlopen(/Users/Elizabeth_Russell/Library/Developer/Xcode/DerivedData/Landmarks-fifnagwlpuhontdywqyzptoyghbg/Build/Intermediates.noindex/Previews/Landmarks/Intermediates.noindex/Landmarks.build/Debug-iphonesimulator/Landmarks.build/Objects-normal/arm64/MapView.1.preview-thunk.dylib, 0x0002): Symbol not found: _$s9Landmarks16MapView_PreviewsV8previewsQrvgZTx |    Referenced from: /Users/Elizabeth_Russell/Library/Developer/Xcode/DerivedData/Landmarks-fifnagwlpuhontdywqyzptoyghbg/Build/Intermediates.noindex/Previews/Landmarks/Intermediates.noindex/Landmarks.build/Debug-iphonesimulator/Landmarks.build/Objects-normal/arm64/MapView.1.preview-thunk.dylib |    Expected in: /Users/Elizabeth_Russell/Library/Developer/Xcode/UserData/Previews/Simulator Devices/49F2A163-EF87-47EC-B1F3-425A9742D1F7/data/Containers/Bundle/Application/0F7E6CF4-2589-42E5-B1C5-EE37941E4186/Landmarks.app/Landmarks) Can someone help me understand why the library is not being loaded? Thank you
Posted
by
Post not yet marked as solved
2 Replies
191 Views
HStack {Text("Calculated number"); TextField("", value: $calculated, format: .number) }             HStack {Text("Calculate number"); TextField("", value: $calculator, format: .number) }             HStack {Text("Calculate way"); TextField("", value: $calculateway, format: .number)} For the code above, Xcode will show error: Can't find $calculated, $calculator and $calculateway. How to solve this error? Also I want to create a Label that shows word:'Result:'and a variable called calresult but I don't know how to make the Label, can anyone give me the code to create the Label I said? I hope the Label will show these text, (calresult)means the data in calresult: Result: (calresult)
Posted
by
Post not yet marked as solved
0 Replies
167 Views
TextField("Calculated number", value: $calculated, format: Float)             TextField("Calculate number", text: $calculator, format: Float)             TextField("Calculate way", text: $calculateway, format: Float) How to solve the errors: 'Cannot find $calculated, $calculator and $calculated in scope'? Also this Label(Maybe I don't know how to make): Label("Result:"+$calresult, systemImage: "42.circle") How to solve this error: 'Cannot find $calresult in scope'?
Posted
by
Post not yet marked as solved
0 Replies
354 Views
Hello there, I stumbled on the issue of observing UserDefaults. My need is to "listening"/observing UD key named "com.apple.configuration.managed" which is responsible for reading provided MDM external plist. I checked that on the opened app it is possible to provide that plist, and app read this payload correctly. My problem is to observing that change, when plist is uploading. Requirement is to support iOS 13, this is why I can't use AppStorage. Despite using some similar solutions like: someone own implementation of AppStorage, and using StackOverflow solutions like this, it still doesn't work. My, I feel, the closest one solution was:   @objc dynamic var mdmConfiguration: Dictionary<String, String> {     get { (dictionary(forKey: MDM.ConfigurationPayloadKey) != nil) ? dictionary(forKey: MDM.ConfigurationPayloadKey)! as! Dictionary<String, String> : Dictionary<String, String>() }     set { setValue(newValue, forKey: MDM.ConfigurationPayloadKey)}   } } class MDMConfiguration: ObservableObject {       //@Binding private var bindedValue: Bool       @Published var configuration: Dictionary = UserDefaults.standard.mdmConfiguration {     didSet {       UserDefaults.standard.mdmConfiguration = configuration     //  bindedValue.toggle()     }   }   private var cancelable: AnyCancellable?   init() {  // init(toggle: Binding<Bool>) {     //_bindedValue = toggle     cancelable = UserDefaults.standard.publisher(for: \.mdmConfiguration)       .sink(receiveValue: { [weak self] newValue in         guard let self = self else { return }         if newValue != self.configuration { // avoid cycling !!           self.configuration = newValue         }       })   } } struct ContentView: View {       @State private var isConfigurationAvailable: Bool = false   @State private var showLoadingIndicator: Bool = true   @ObservedObject var configuration = MDMConfiguration()       var body: some View {           GeometryReader { geometry in               let width = geometry.size.width       let height = geometry.size.height                             VStack {         Text("CONTENT -> \(configuration.configuration.debugDescription)").padding()         Spacer()         if !configuration.configuration.isEmpty {           Text("AVAILABLE").padding()         } else {           Text("NIL NULL ZERO EMPTY")             .padding()         }       }        }   } } But it still doesn't ensure any changes in view, when I manually click on f.e. button, which prints the configuration in the console when it has uploaded, it does it well. Please help, my headache is reaching the zenith. I am a newbie in Swift development, maybe I did something weird and stupid. I hope so :D Thank in advance!
Posted
by
Post not yet marked as solved
0 Replies
164 Views
Any idea how to implement an alamofire/ or http login request for this kind of json data { "data":{ "email": "myemail@...", "password":"12345678", "token":"" } } since i don't know how to read these curled bracelets "{" well, i need a severe help ! my data is from a url and not a json file, it is a url request
Posted
by
Post not yet marked as solved
0 Replies
170 Views
I created a slider, but sometimes it slides and sometimes it doesn't respond
Posted
by
Post not yet marked as solved
0 Replies
360 Views
Currently NaviagitonView on macOS creates a side panel. And then navigationViewStyle does not support stack view for macOS. Given this, is there currently a method to totally switch the content of a window from one view to another on macOS?
Posted
by
Post not yet marked as solved
0 Replies
458 Views
I have a class where I get data from firebase. But I can't get it exactly as I want, for example document("abc" ) here I need to get the name "abc" from another place, different name may come according to each click. I can't assign this to the class I'm getting the data from, can you help me? import Firebase struct StadiumNameView: View { var body: some View { VStack{ List(stadiumnameeeee) { i in NavigationLink(destination: SelectedStadiumView(selectedStadium:i.name)){ Text(i.name) } } } } } struct StadiumNameView_Previews: PreviewProvider { static var previews: some View { StadiumNameView() } } I need to pass the "i.name" here to the following class. import Firebase class UserInfoModel : ObservableObject { @Published var city="" @Published var email="" @Published var name="" @Published var surname="" @Published var phone="" @Published var town="" @Published var type="" @Published var id="" @Published var birthday="" @Published var favStadium=[String]() init(){ let db=Firestore.firestore() db.collection("Users").document(Auth.auth().currentUser!.uid).addSnapshotListener { (snapshot, error) in if error == nil { if let city=snapshot?.get("City") as? String { self.city=city } if let email=snapshot?.get("Email") as? String { self.email=email } if let name=snapshot?.get("Name") as? String { self.name=name } if let surname=snapshot?.get("Surname") as? String { self.surname=surname } if let phonenumber=snapshot?.get("Phone") as? String { self.phone=phonenumber } if let town=snapshot?.get("Town") as? String { self.town=town } if let type=snapshot?.get("Type") as? String { self.type=type } if let id=snapshot?.get("User") as? String { self.id=id } if let birthday=snapshot?.get("DateofBirth") as? String { self.birthday=birthday } if let favStadiums=snapshot?.get("FavoriteStadiums") as? [String]{ self.favStadium=favStadiums } } } } }
Posted
by
Post not yet marked as solved
0 Replies
253 Views
I have 2 lists on different screens. It sorts the other list according to the data in the list I printed first. For example, if "name" is written in the list, it pulls data from firebase and lists it according to the "name" data in the other list. But the first time I click on the list, the empty list comes up and the next time I click, the data comes up according to the first click. @ObservedObject var findStadium=FindStadium() @State var selectedTown="" @State var stadiumNameArray=[String]() var body: some View { NavigationView { List(findStadium.townArray){ towns in NavigationLink(destination: StadiumNameView().onAppear{ selectedTown=towns.town let firestoreDatabase=Firestore.firestore() firestoreDatabase.collection("Stadiums").order(by: "Name",descending: false).addSnapshotListener { (snapshot, error) in if error != nil { print(error?.localizedDescription ?? "Error") } else { if snapshot?.isEmpty != true && snapshot != nil { stadiumnameeeee.removeAll(keepingCapacity: false) print(stadiumnameeeee) for document in snapshot!.documents { if let Name = document.get("Town") as? String { if Name==self.selectedTown { let stadiumName=document.get("Name") as! String self.stadiumNameArray.append(stadiumName) stadiumnameeeee.append(stadiumName) print(stadiumName) print(stadiumnameeeee) } } } } } } }) { Text(towns.town) } } .navigationBarTitle("İstanbul",displayMode:.large) //başka şehirler eklenirse düzenle } }} and other view var body: some View { VStack{ List(stadiumnameeeee,id:\.self) { i in NavigationLink(destination: SelectedStadiumView()){ Text(i) } } } }} where am i doing wrong? please help!
Posted
by
Post not yet marked as solved
3 Replies
1.2k Views
Using SwiftUI's new Table container, how can I add a context menu that appears when Control-clicking a row? I can add the contextMenu modifier to the content of the TableColumn, but then I will have to add it to each individual column. And it only works above the specific text, not on the entire row: I tried adding the modifier to the TableColumn itself, but it shows a compile error: Value of type 'TableColumn<RowValue, Never, Text, Text>' has no member 'contextMenu' Here's what I have in terms of source code, with the contextMenu modifier in the content of the TableColumn: struct ContentView: View { @Environment(\.managedObjectContext) private var viewContext @FetchRequest(sortDescriptors: [NSSortDescriptor(keyPath: \Item.name, ascending: true)]) private var items: FetchedResults<Item> @State private var sortOrder = [KeyPathComparator(\Item.name)] @State private var selection = Set<Item.ID>() var body: some View { NavigationView { Table(items, selection: $selection, sortOrder: $items.sortDescriptors) { TableColumn("Column 1") { Text("Item at \($0.name!)") .contextMenu { Button(action: {}) { Text("Action 1") } Divider() Button(action: {}) { Text("Action 2") } Button(action: {}) { Text("Action 3") } } } TableColumn("Column 2") { Text($0.id.debugDescription) } } .toolbar { ToolbarItem { Button(action: addItem) { Label("Add Item", systemImage: "plus") } } } if selection.isEmpty { Text("Select an item") } else if selection.count == 1 { Text("Selected \(items.first(where: { $0.id == selection.first! })!.id.debugDescription)") } else { Text("Selected \(selection.count)") } } } } So, how can I add a context menu to the entire row inside the Table?
Posted
by
Post not yet marked as solved
2 Replies
435 Views
I am trying to learn swift UI now and everything was going smoothly. The next day I try to open the project right back up but I can't see the canvas. I have tried numerous times but they all don't work. The diagnostics say this : file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/usr/lib/swift/shims/RuntimeStubs.h' has been modified since the module file '/var/folders/ky/d075t_497gs6yynw5cd489hw0000gn/C/clang/ModuleCache/HP5PGJ664UGB/SwiftShims-2TTN5UXQBRCCQ.pcm' was built: mtime changed CompileDylibError: Failed to build ContentView.swift Compiling failed: file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/usr/lib/swift/shims/RuntimeStubs.h' has been modified since the module file '/var/folders/ky/d075t_497gs6yynw5cd489hw0000gn/C/clang/ModuleCache/HP5PGJ664UGB/SwiftShims-2TTN5UXQBRCCQ.pcm' was built: mtime changed :0: error: file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/usr/lib/swift/shims/RuntimeStubs.h' has been modified since the module file '/var/folders/ky/d075t_497gs6yynw5cd489hw0000gn/C/clang/ModuleCache/HP5PGJ664UGB/SwiftShims-2TTN5UXQBRCCQ.pcm' was built: mtime changed :0: note: please rebuild precompiled header '/var/folders/ky/d075t_497gs6yynw5cd489hw0000gn/C/clang/ModuleCache/HP5PGJ664UGB/SwiftShims-2TTN5UXQBRCCQ.pcm' :1:9: note: in file included from :1: #import "LibcOverlayShims.h"         ^ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/usr/lib/swift/shims/LibcOverlayShims.h:21:2: error: file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/usr/lib/swift/shims/RuntimeStubs.h' has been modified since the module file '/var/folders/ky/d075t_497gs6yynw5cd489hw0000gn/C/clang/ModuleCache/HP5PGJ664UGB/SwiftShims-2TTN5UXQBRCCQ.pcm' was built: mtime changed #include "Visibility.h"  ^ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/usr/lib/swift/shims/LibcOverlayShims.h:21:2: note: please rebuild precompiled header '/var/folders/ky/d075t_497gs6yynw5cd489hw0000gn/C/clang/ModuleCache/HP5PGJ664UGB/SwiftShims-2TTN5UXQBRCCQ.pcm' #include "Visibility.h"  ^ :0: error: missing required module 'SwiftOverlayShims' ================================== |  BuildInvocationError |   |  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -F /Applications/Xcode.app/Contents/SharedFrameworks-iphonesimulator -enforce-exclusivity=checked -DDEBUG -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk -target arm64-apple-ios15.0-simulator -Xfrontend -serialize-debugging-options -enable-testing -swift-version 5 -I /Users/nicholasstefadouros/Library/Developer/Xcode/DerivedData/Landmarks-gcahliobeozomohdnhybmlhirqoj/Build/Intermediates.noindex/Previews/Landmarks/Products/Debug-iphonesimulator -F /Users/nicholasstefadouros/Library/Developer/Xcode/DerivedData/Landmarks-gcahliobeozomohdnhybmlhirqoj/Build/Intermediates.noindex/Previews/Landmarks/Products/Debug-iphonesimulator -emit-localized-strings -emit-localized-strings-path /Users/nicholasstefadouros/Library/Developer/Xcode/DerivedData/Landmarks-gcahliobeozomohdnhybmlhirqoj/Build/Intermediates.noindex/Previews/Landmarks/Intermediates.noindex/Landmarks.build/Debug-iphonesimulator/Landmarks.build/Objects-normal/arm64 -c -j8 -serialize-diagnostics -Xcc -I/Users/nicholasstefadouros/Library/Developer/Xcode/DerivedData/Landmarks-gcahliobeozomohdnhybmlhirqoj/Build/Intermediates.noindex/Previews/Landmarks/Intermediates.noindex/Landmarks.build/Debug-iphonesimulator/Landmarks.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/nicholasstefadouros/Library/Developer/Xcode/DerivedData/Landmarks-gcahliobeozomohdnhybmlhirqoj/Build/Intermediates.noindex/Previews/Landmarks/Intermediates.noindex/Landmarks.build/Debug-iphonesimulator/Landmarks.build/Landmarks-generated-files.hmap -Xcc -I/Users/nicholasstefadouros/Library/Developer/Xcode/DerivedData/Landmarks-gcahliobeozomohdnhybmlhirqoj/Build/Intermediates.noindex/Previews/Landmarks/Intermediates.noindex/Landmarks.build/Debug-iphonesimulator/Landmarks.build/Landmarks-own-target-headers.hmap -Xcc -I/Users/nicholasstefadouros/Library/Developer/Xcode/DerivedData/Landmarks-gcahliobeozomohdnhybmlhirqoj/Build/Intermediates.noindex/Previews/Landmarks/Intermediates.noindex/Landmarks.build/Debug-iphonesimulator/Landmarks.build/Landmarks-all-target-headers.hmap -Xcc -iquote -Xcc /Users/nicholasstefadouros/Library/Developer/Xcode/DerivedData/Landmarks-gcahliobeozomohdnhybmlhirqoj/Build/Intermediates.noindex/Previews/Landmarks/Intermediates.noindex/Landmarks.build/Debug-iphonesimulator/Landmarks.build/Landmarks-project-headers.hmap -Xcc -I/Users/nicholasstefadouros/Library/Developer/Xcode/DerivedData/Landmarks-gcahliobeozomohdnhybmlhirqoj/Build/Intermediates.noindex/Previews/Landmarks/Products/Debug-iphonesimulator/include -Xcc -I/Users/nicholasstefadouros/Library/Developer/Xcode/DerivedData/Landmarks-gcahliobeozomohdnhybmlhirqoj/Build/Intermediates.noindex/Previews/Landmarks/Intermediates.noindex/Landmarks.build/Debug-iphonesimulator/Landmarks.build/DerivedSources-normal/arm64 -Xcc -I/Users/nicholasstefadouros/Library/Developer/Xcode/DerivedData/Landmarks-gcahliobeozomohdnhybmlhirqoj/Build/Intermediates.noindex/Previews/Landmarks/Intermediates.noindex/Landmarks.build/Debug-iphonesimulator/Landmarks.build/DerivedSources/arm64 -Xcc -I/Users/nicholasstefadouros/Library/Developer/Xcode/DerivedData/Landmarks-gcahliobeozomohdnhybmlhirqoj/Build/Intermediates.noindex/Previews/Landmarks/Intermediates.noindex/Landmarks.build/Debug-iphonesimulator/Landmarks.build/DerivedSources -Xcc -DDEBUG=1 -working-directory "/Users/nicholasstefadouros/Desktop/Coding Course And Resources/Xcode Projects/Landmarks" /Users/nicholasstefadouros/Library/Developer/Xcode/DerivedData/Landmarks-gcahliobeozomohdnhybmlhirqoj/Build/Intermediates.noindex/Previews/Landmarks/Intermediates.noindex/Landmarks.build/Debug-iphonesimulator/Landmarks.build/Objects-normal/arm64/ContentView.1.preview-thunk.swift -o /Users/nicholasstefadouros/Library/Developer/Xcode/DerivedData/Landmarks-gcahliobeozomohdnhybmlhirqoj/Build/Intermediates.noindex/Previews/Landmarks/Intermediates.noindex/Landmarks.build/Debug-iphonesimulator/Landmarks.build/Objects-normal/arm64/ContentView.1.preview-thunk.o -module-name Landmarks_PreviewReplacement_ContentView_1 -Onone -Xfrontend -disable-modules-validate-system-headers -gline-tables-only
Posted
by
Post not yet marked as solved
2 Replies
673 Views
In my app, I need to have an onscreen button initiate a screenshot (which then gets saved to Photos, etc). Currently, every method I've tried from the forums (every version of UIGraphicsGetImageFromCurrentImageContext...) will capture everything EXCEPT the live feed from the camera, which is running as a sublayer on my view. Everything from labels to buttons and even background color shows up in the pictures using those methods but no matter what, the image from the camera is just a blank space on the pictures. However, when my app is running, I can press the two buttons and THAT picture always has the image from the camera included! I need this to happen with my onscreen button and that's what I just can't get to happen the same way. Does anyone know the actual function/extension/code that runs whenever someone presses the hardware buttons to initiate a screenshot? Or how to accomplish getting everything that's onscreen at a given time to be include in a screenshot, regardless of what layer(s) it's in?
Posted
by
Post marked as solved
1 Replies
430 Views
https://developer.apple.com/documentation/swiftui/table Following the documentation above to build a test table, but I am getting the below errors on the first table: 'buildBlock' is unavailable in iOS 'init(_:columns:)' is unavailable in iOS 'Table' is unavailable in iOS Xcode version: Version 13.2.1 (13C100) MacOS 12.1 Not sure what these errors mean, any help would be greatly appreciated. Thanks!
Posted
by
Post not yet marked as solved
0 Replies
212 Views
Hi Team, We are developing an IoT project using Flutter. We have a requirement for our client. We have developed a mobile app that displays a list of nearby gateway wifi List. The user connects that Wifi and gets gateway information. Description: The app will scan for nearby SSIDs, the user can select any one of them, and the user can insert the password.  After successfully connecting, the user tries to connect to ssh client using host, port, username, password. Then the user used some commands to fetch HED/LED Logs information. Can you help me with how to archive it in IOS? Thanks, Sitakanta Sundaray
Posted
by
Post marked as solved
1 Replies
579 Views
[Required] Xcode 13 pod installed : 'QImageDownloader' 'QImageDownloader/Rx' 'RealmSwift' 'SwiftyRSA' 'BDGhostover' 'Charts' 'ComScore' 'Gifu' 'GoogleAnalytics' 'Google-Mobile-Ads-SDK',  'GoogleMobileAdsMediation 'Firebase' 'FirebaseMessaging' 'Firebase/Analytics' 'Firebase/Crashlytics' 'Firebase/DynamicLinks' 'Firebase/RemoteConfig' 'ImageViewer.swift' 'lottie-ios' 'OguryAds', '2.5.0' 'OguryChoiceManager', '3. 'RealmSwift' 'RxAnimated' 'RxAppState' 'RxCocoa' 'RxRealm' 'RxSwift', '~> 5' 'RxDataSources' 'SwiftyStoreKit' 'XCoordinator' 'XCoordinator/RxSwift' When I try to use swiftUI file the preview does not work at all. I need to uncheck the automatically refresh canvas in the editor. previews.txt
Posted
by
Post not yet marked as solved
1 Replies
414 Views
In the "What's new in Foundation" and "What's new in SwiftUI" talks there were examples of creating custom Attributed String styles. The example shown was for a rainbow style. They showed creating the style, serializing the style, using the style in a String - but did not show how to actually render the text in the rainbow style. How is that part done in SwiftUI. ie if I have Text("My fake example of ^[a custom style](customStyle: redAndEmphasized).") How would i create the piece that renders "a custom style" with foregroundColor red and a heavy font? Thanks, Daniel
Posted
by
Post not yet marked as solved
0 Replies
163 Views
I want to use the Table component to achieve the following functions Right click the column header to pop up context menu Right click each row to pop up context menu I found that TableColumn and TableRow objects are not of type view. Setting contextMenu is not supported. I can set the ContextMenu on the cell in the following ways, but it only works inside the cell, and clicking on the blank part does not take effect. TableColumn("Given Name", value: \.givenName) { person in Text(person.givenName) .contextMenu(menuItems: { Button { } label: { Text("New Order") } }) } How to set independent context menus on rows and column headers?
Posted
by