Search results for

column

2,046 results found

Post

Replies

Boosts

Views

Activity

Reply to SwiftUI - ScrollView with LazyVGrid and onTap, scrolling randomly by itself
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:
May ’23
Reply to SwiftUI - ScrollView with LazyVGrid and onTap, scrolling randomly by itself
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:
May ’23
Sudo Command Unusable
I change my /private/etc permissions to eveybody can read and write, and applied this permission to all sub-folders and files. (something ****** to do)After that, when I use sudo command something went wrong:sudo: unable to stat /etc/sudoers: Permission deniedsudo: no valid sudoers sources found, quittingsudo: unable to initialize policy pluginAlso, I make a change to my sudoer file when trying to solve the problem.Here is its content:----------------------------------------------------------------------------------------------------------------------------------------# # Sample /etc/sudoers file. # # This file MUST be edited with the 'visudo' command as root. # # See the sudoers man page for the details on how to write a sudoers file. ## # Override built-in defaults ## Defaults env_reset Defaults env_keep += BLOCKSIZE Defaults env_keep += COLORFGBG COLORTERM Defaults env_keep += __CF_USER_TEXT_ENCODING Defaults env_keep += CHARSET LANG LANGUAGE LC_ALL LC_COLLATE LC_CTYPE Defaults env_keep += LC_MESSAGES LC_M
1
0
1.2k
May ’23
Swift - access attribute in array of core data entities in a table column via a variable
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
1
0
861
Apr ’23
NavigationSplitView 2-column loses state when minimized on iPad
Hello! I've noticed that when I am using NavigationSplitView and I minimize the app on iPadOS and then resume, if I am using a 2 column setup it loses state upon resume. This does not appear to happen on with a 3 column setup though. I'm wondering if others have run into this and if anyone has figured out a way around it. It seems like it's a bug and I should file a bug for it, but wanted to check with more people first. Here's some example code, run it, select your number of columns, then minimize the app, count to 3 (because why not!) and open the app and you'll notice that $selection is now nil. import SwiftUI struct Item: Identifiable, Hashable { var id: Int var name: String var description: String } struct ContentView: View { @State var selection: Item? var items: [Item] = [ .init(id: 1, name: One, description: Is the loneliest number), .init(id: 2, name: Two, description: Two can be as bad as one), .init(id: 3, name: Three, description: Three Dog Night) ] var body: some View {
1
0
730
Apr ’23
Reveal in Finder fails: anything inside home folder only reveals home
When i do reveal in finder from literally any app, including spotlight searches FROM the finder, if the item i'm revealing is in a sub-folder of my Home folder, it ONLY reveals my Home folder. for example, i have a structure like this: (home)/Documents/Filing Cabinet/Manuals/PowerSwitch/PowerSwitch.pdf Say i forgot where i put that, so i do a spotlight search for powerswitch, and spotlight helpfully locates everything with that name, so i scroll to the bottom (why is it at the bottom?) and pick search in finder, which shows a nice window with all the search results. I see a folder called PowerSwitch so i: a) double click it, or: b) right click and pick show in enclosing folder Either way, a new window comes up showing ONLY the Home folder. Note this ONLY happens when i have column view as the default. If i have list view as the default, it DOES work, showing a window containing the actual folder or file i'm interested in, but if i then switch said window to column view (which is what i alway
2
0
953
Apr ’23
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