Search results for

column

2,052 results found

Post

Replies

Boosts

Views

Activity

Reply to NSTableView dragging source image
Hi Dragan, I was faced with the same issue, and came across your posting while searching for an approach. I want to drag whole-row images regardless of which column was targeted by the mouse. Building on techniques described at https://www.mail-archive.com/cocoa-dev%40lists.apple.com/msg108722.html (for some reason this web app won't let me format that as a link) and here, I came up with this: func tableView(_ tableView: NSTableView, draggingSession session: NSDraggingSession, willBeginAt screenPoint: NSPoint, forRowIndexes rowIndexes: IndexSet) { session.enumerateDraggingItems(options: .concurrent, for: nil, classes: [NSPasteboardItem.self], searchOptions: [:]) { (draggingItem, index, stop) in // Get the row index for this drag item. Could cheat and map `index` to `rowIndexes`, but this is cleaner. guard let pasteboardItem = draggingItem.item as? NSPasteboardItem, let rowIndex = pasteboardItem.propertyList(forType: com.example.RowIndexPasteboardType) as? Int else { stop.pointee = true return } // Co
Topic: UI Frameworks SubTopic: AppKit Tags:
Apr ’23
NSTableView dragging source image
I have a simple problem, but I’m not able to solve it in an easy way, so I suspect I’m doing something wrong. I have a simple view-based NSTableView, which is a dragging source. The data being dragged are provided to the pasteboard using the standard data source method - [NSObject tableView:writeRowsWithIndexes:toPasteboard:]. When rows of the table view are dragged, AppKit automatically creates a dragging image consisting of the visual copy for all dragged rows and all columns of the table view. If I want only particular columns, I can override -[NSTableView dragImageForRowsWithIndexes:tableColumns:event:offset:] and include only the columns I want in the dragged image. Since -[NSObject tableView:writeRowsWithIndexes:toPasteboard:]is rendered deprecated as of macOS 11, I want to use the alternative (which also supports multiple item dragging) -[NSObject tableView:pasteboardWriterForRow:]. However, when I use this method, AppKit creates a dragging image consisting of the visual copy
Topic: UI Frameworks SubTopic: AppKit Tags:
1
0
1.1k
Apr ’23
Async task cancelled in Refreshable Modifier on Scrollview on iOS 16
I'm trying to use the refreshable modifier on a Scrollview in an app that targets iOS 16. But the asynchronus task gets cancelled during the pull to refresh gesture. It was tested on a physical device. Here is some code that demonstrates the problem and an image with the error printed: ExploreViewModel.swift class ExploreViewModel: ObservableObject { @Published var randomQuotes: [Quote] = [] init() { Task { await loadQuotes() } } @MainActor func loadQuotes() async { let quotesURL = URL(string: https://type.fit/api/quotes)! do { let (data, urlResponse) = try await URLSession.shared.data(from: quotesURL) guard let response = urlResponse as? HTTPURLResponse else { print(no response); return} if response.statusCode == 200 { let quotes = try JSONDecoder().decode([Quote].self, from: data) randomQuotes.append(contentsOf: quotes) } } catch { debugPrint(error) debugPrint(error.localizedDescription) } } func clearQuotes() { randomQuotes.removeAll() } } Content.swift import SwiftUI struct ContentView: View { @StateObjec
2
0
2.2k
Apr ’23
Reply to Conflicting arguments to generic parameter 'Content' on NavigationLink for @Binding var
import SwiftUI struct AfficherUneListe: View { @Binding var liste : Liste @Binding var showNavigationBar: Bool var body: some View { Spacer() Text(Les cartes) .font(.headline) ScrollView { LazyVGrid(columns: [GridItem(.adaptive(minimum: 100))], spacing: 5) { ForEach(liste.cartes) { c in NavigationLink(destination: ModifierUneCarte(carte: c)) { VStack { RoundedRectangle(cornerRadius: 10) .foregroundColor(.white) .shadow(radius: 3) .padding(5) // Ajouter un padding supplémentaire .overlay( VStack { Text(c.devant) .font(.system(size: 14)) Divider() Text(c.derriere) .font(.system(size: 14)) } ) } .frame(width: 100, height: 100) } } } } .navigationBarItems(trailing: HStack { Button(action: { // Code pour le premier bouton }) { Image(systemName: play) } Button(action: { // Code pour le deuxième bouton }) { Image(systemName: trash) } }) .navigationTitle(liste.nom) } } struct AfficherUneListe_Previews: PreviewProvider { static var previews: some View { let liste = Liste(nom: Liste 1, cartes: [ Carte(devant:
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’23
How can I fix Context in environment is not connected to a persistent store coordinator
I am working on an app that will allow users to share or save the view via a share sheet. To capture the view I am using the ImageRenderer. When I go to click on the share button, it does not work and says, Unable to render flattened version of PlatformViewControllerRepresentableAdaptor, Never, _UnaryViewAdaptor>>. When I go to the issues it will say, Context in environment is not connected to a persistent store coordinator: . How can I fix this. This is the code. struct DividendView: View { @Environment(.managedObjectContext) var moc @FetchRequest(sortDescriptors: [ SortDescriptor(.stock_name) ]) var dividends: FetchedResults @State private var showingAddScreen = false @State private var showingShare = false // @EnvironmentObject var vm = ViewModel() @State private var renderedImage: Image? @State private var selectedName: String? @State private var expanded: Bool = false let dividend: Dividend // @State private var items: [Any] = [] // @State private var sheet: Bool = false // let columns = [
2
0
1.2k
Apr ’23
Reply to Tabular classification using Create ML Components
A tabular classifier will return both the classification probabilities and the most likely labels. If your target column name is target the predicted labels column is also going to be target while the probability distributions is going to be in targetProbabilities. You can always print the whole data frame with print(result) and see what the columns are. Hope this helps.
Apr ’23
Tabular classification using Create ML Components
I am working on a project that involves tabular classification using Create ML Components and I'm having trouble getting my model to work correctly. I've been following the official documentation here: https://developer.apple.com/documentation/createmlcomponents/ and also i have followed the wwdc talks. This one seems to be the most relevant one: https://developer.apple.com/wwdc22/10019 In that talk the construction of a tabular regressor is explained(20:23 Tabular regressor) . I tried using BoostedTreeClassifier similar to that. I am having trouble getting it to work though. While training with 5 featureColumns and one annotation columns appears to have worked. i am unsure how to get the label (the categorical value that the model is supposed to return) after calling .predict . This is the last bit of the example from apple (tabular regression) static func predict( type: String, region: String, volume: Double ) async throws -> Double { let model = try task.read(from: parametersURL) let dataFrame:
1
0
1.2k
Apr ’23
SwiftUI LazyVGrid Positioning
Hello, I want to create a dashboard with LazyVGrid. I made a lineup like 2-2-1. It's okay as the images in the first 2 rows are the same, but I can't fit last image exactly because the bottom image is bigger than the others. I am attaching a screenshot for your better understanding. How can I center currency converter image overflowing from the screen? struct ContentView: View { let columns = [ GridItem(.fixed(150), spacing: 30), GridItem(.fixed(150), spacing: 30),] var body: some View { NavigationView{ LazyVGrid(columns: columns) { // WEIGHT * MASS NavigationLink(destination: UnitView()) { Image(systemName: scalemass) .font(.system(size: 60)) .padding() .frame(width: 150, height: 150, alignment: .center) .background(Rectangle().fill(Color.purple.opacity(0.5)) .shadow(radius: 3)).cornerRadius(20) .foregroundColor(.black) .overlay(Text(Weight) .foregroundColor(.black) .padding() .font(.system(size: 22)), alignment: .bottom )} //DISTANCE * NavigationLink(destination: DistanceView()) {
2
0
4.3k
Apr ’23
Reply to SwiftUI LazyVGrid Positioning
Hi, I saw your question a few hours ago and I don't know if you are still looking for an answer at this time. Anyways, here is the solution with an explanation for anyone who might be interested in it. You have a LazyVGrid with two columns which is what you are seeing in the screenshot you've provided. UnitView(), TemperatureView() and CurrencyView() form the first column, whereas DistanceView() and TimeView() form the second column. Since you did not specify the alignment property, it assumed its default value, which is HorizontalAlignment.center in the case of LazyVGrid. If you specify alignment as HorizontalAlignment.leading, then the view would look somewhat like how you want it to look. But, it doesn't look good because the cards are not in the middle of the screen. To solve this, you would have to embed LazyVGrid into a LazyVStack, take the CurrencyView() out of the LazyVGrid, and place it outside LazyVGrid but within LazyVStack. struct ContentView: View { let columns
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’23
NavigationLink selected state area is larger than the underlying view
I'm using a NavigationSplitView with two columns for a macOS app. The sidebar column shows a list of items and the right pane shows the details for the selected item. I'm using NavigationLink to create clickable sidebar items and pass my own View-type struct that displays the row information. When I decided to add a slight background color to the rows & slight hover state, I noticed that the row view container is smaller than the NavigationLink when selected (I made the colors brighter to emphasize the issue - rows have a gray background & brighter gray hover state and blue is the built-in styling provided by NavigationLink). My code for the NavigationSplitView which lives in the body of the main ContentView: NavigationSplitView(columnVisibility: $columnVisibility) { VStack{ if userSettings.cases.isEmpty { Text(Press + to add your first case) .font(.title2) .foregroundColor(.gray) .multilineTextAlignment(.center) } else { List(userSettings.cases, selection: self.$selectedCase) { case
1
0
1.1k
Apr ’23