Search results for

“column”

2,085 results found

Post

Replies

Boosts

Views

Activity

Reply to Why overlay is not on top
I think your problem is in the .padding(8) line. When you have that padding it adds 8px to all four external sides of the Text label, making it too small to fit the text on one line. You can achieve your desired look by reducing the font size, too, but that's probably not of much use. I've just put this into a new project, and Xcode is showing the preview in an iPhone 14 Pro (or Max) where the result is perfectly fine, because that device is quite wide. I've added .frame(width 380) to the ScrollView so it can be seen on a smaller screen. I've given the various elements a background colour so you can see where they interact: struct ContentView: View { var body: some View { ScrollView { LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible())]) { Stat() Stat() Stat() Stat() } } .frame(width: 380) // Change this to simulate smaller devices } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } struct Stat: View { var body: some View { VStack { Text(
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’22
UINavigationController inside UISplitViewController's UISplitViewControllerColumnSupplementary Doesn't Appear on Mac Catalyst
Working on a Mac Catalyst app. I have a UInavigationController. On iOS this is full screen but on Mac Catalyst I'm using it inside a UISplitViewController in the supplementary column. This view controller's root view controller has a navigationItem which configures a UISearchController. The search bar is nowhere to be found unless I set it to UINavigationItemSearchBarPlacementStacked. So is UINavigationItemSearchBarPlacementInline not supported for the supplementary column of a UISplitViewController? If that's the case I'm fine with that actually but there's got to be a way to make UINavigationItemSearchBarPlacementStacked look a little better on Mac? The search bar border is barely visible on a white background.
1
0
1.1k
Oct ’22
LazyHGrid Equal Distribution
Wish to ask for suggestions. My goal is to have a view where user inputs an array of strings. Depending on the number of strings, should have equal distribution of spacing between them. E.g. 5 items. 1st item should be top, last item should be bottom while the 2nd-4th should be in between and all of them should have equal spacing. This is what I have import SwiftUI struct MyView: View { @State private var labels: [String]? var labels = [Great, Major, Strong, Moderate, Small] var colors = [.blue, .red] HStack { Spacer() LazyHGrid(rows: [GridItem(.adaptive(minimum: 120))]) { if let labels { Group { ForEach(labels, id:.self) { label in Text(label) } } } } .frame(maxHeight: .infinity) Rectangle() .foregroundColor(.clear) .background(LinearGradient(gradient: Gradient(colors: colors ?? []), startPoint: .top, endPoint: .bottom)) Spacer() } } The result is not what I expected it to be. Notice the orange arrows. If i add more strings, [Great, Major, Strong, Moderate, Small, Great, Major, Strong, Moderate, Small], it b
1
0
482
Oct ’22
Making table header opaque to scrolling rows in SwiftUI
I am working on converting an application I wrote for iOS from using UIKit to using SwiftUI. So far, it looks like I’ve been able to get just about everything working with SwiftUI except for one thing. I have a table view that displays several rows of information in a few columns. The table has a single header at the top containing titles for each column. However, there is an aspect of the table view that introduced an undesirable behavior. When scrolling the content, row scrolling upward would appear underneath the header row. The desire was to have the header row be opaque with regard to the table content yet still allow background content underneath the header to show through. In UIKit I ended up implementing a hack of sorts to prevent content of scrolling rows from appearing directly behind the header. To do this, during scrolling the code was calling the UITableView.rectForHeader method and applying a mask to the layer of any rows that might be intersecting that header rectangle. That m
1
0
692
Oct ’22
Reply to List is Disappearing
`struct ContentView: View { @Environment(.managedObjectContext) var moc @FetchRequest(sortDescriptors: [ SortDescriptor(.date) ]) var taxes: FetchedResults @State private var showingAddScreen = false // @EnvironmentObject var vm = ViewModel() @State var PDFUrls: URL? @State var showSheet: Bool = false @State private var selectedName: String? @State private var expanded: Bool = false let tax: Tax // @State private var items: [Any] = [] // @State private var sheet: Bool = false // let columns = [GridItem(.fixed(50)), GridItem(.fixed(50)), GridItem(.fixed(50)), GridItem(.fixed(50)), GridItem(.fixed(50))] var body: some View { // NavigationView { // VStack { VStack { HStack { // padding() EditButton() // .background(Color.yellow) .padding(.leading, 20) Spacer() Button { exportPDF { self } completion: { status, url in if let url = url, status { self.PDFUrls = url self.showSheet.toggle() } else { print(Failed to produce PDF) } } } label: { Image(systemName: square.and.arrow.up) //.background(Color.yellow)
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’22
Reply to Bug in StoreKit 2 in iOS 15.5-7
Hi, unfortunately this is an issue in Xcode 14.0. The issue is resolved in Xcode 14.1 RC, so if you build your app with that version it will be able to use these properties on iOS versions earlier than iOS 16.0. There is a workaround you can use to use these APIs in apps built with Xcode 14.0 and 14.0.1 listed in the Xcode 14.0 release notes, I'll quote it here: Using the following StoreKit properties and methods on apps with a minimum deployment target below iOS 16, macOS 13, watchOS 9, and tvOS 16 will cause the app to crash at launch when running on systems earlier than iOS 16, macOS 13, watchOS 9 and tvOS 16: priceFormatStyle and subscriptionPeriodFormatStyle on Product values environmentStringRepresentation and recentSubscriptionStartDate on Product.SubscriptionInfo.RenewalInfo values environmentStringRepresentation on Transaction values dateRange(referenceDate:) and formatted(_:referenceDate:) on Product.SubscriptionPeriod values (99962885) (FB11516463) Workaround: For each target using a StoreKit API l
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’22
Fit SwiftUI grid columns to the contents
My grids expand widthways to take up all the space it can. I can stick it in a frame and limit the size. But is there a way to get the columns to shrink to fit the contents plus padding? That would be neater, and probably more robust if the text changes size. FWIW most of my grids contain only text, and I don't use a lot of columns.
1
0
1.5k
Oct ’22
Reply to Passing an array into struct
Sorry this might be better than the previous post... var gameImport = 24,exam.dwindled.span,Short for examination,Reduced gradually in size,The total length of something from end to end,_ _ _ _ . _ w _ _ d _ _ d . _ _ _ n,16,///cracked.shadowed.private,The Vase was (?) when it toppled over,A part of the house is (?) by a tree every day,We like to talk in (?) when we want to keep it : secret,_ _ _ _ _ _ . _ _ _ _ _ _ . _ _ _ a t e,98,///spilling.dances.backbone,Causing or allowing liquid to flow over the edge : of its container,A series of steps that match the speed and : rhythm of a piece of music,The column of bones in the back which sustains : and gives firmness to the frame,_ p _ l l _ n . a _ c _ s._ a _ _ b _ n ,93,///inwards.habitat.buttered,Toward the centre or interior,Place where anything is commonly found,Covered or spread with butter, _ _ w _ r _ . a b t _ t._ u _ _ e _ e d, a e m x , d i l e n , p a s , d r a c c k e , d s a d o w e h , v r p i , g i s i , n d e , k o b c e , n s i a d ,
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’22
Reply to Passing an array into struct
Thank you for your time 🙏🏻 This is what I have done in Playgrounds... var printCards = // No required if NOT printing the cards // Imported .csv file pasted in (var gameImport) below //////////////// var gameImport = 24,exam.dwindled.span,Short for examination,Reduced gradually in size,The total length of something from end to end,_ _ _ _ . _ w _ _ d _ _ d . _ _ _ n,16,///cracked.shadowed.private,The Vase was (?) when it toppled over,A part of the house is (?) by a tree every day,We like to talk in (?) when we want to keep it : secret,_ _ _ _ _ _ . _ _ _ _ _ _ . _ _ _ a t e,98,///spilling.dances.backbone,Causing or allowing liquid to flow over the edge : of its container,A series of steps that match the speed and : rhythm of a piece of music,The column of bones in the back which sustains : and gives firmness to the frame,_ p _ l l _ n . a _ c _ s._ a _ _ b _ n ,93,///inwards.habitat.buttered,Toward the centre or interior,Place where anything is commonly found,Covered or spread with butter, _ _ w _
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’22
Develop In Swift Explorations - Unit 1 Build
In Part 1 of Unit 1 Build Students must set up the project using the App template feature. On page 55 the viewer window shows in the left column a list of files that should be in the photo frame. These include: AppDelegate, SceneDelegate, ViewController, Main, Assets and LaunchScreen. I can see this on my computer, however when my students follow the same steps. They only see the files name ad ContentView What are we doing wrong?!
3
0
818
Oct ’22
Reply to Implementing a cursor on both a cell and a row while using NSTableView
I forgot to show how to call this func: func control(_ control: NSControl, textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool { // 1. get row and column, multiplexed in sender's tag guard let textField = control as? TextField else { return false } let rowIndiv = textField.tag % (256 * 256) let colVar = (highWordTag - rowIndiv) / (256 * 256) selectedRowInDataTable = rowIndiv // a var of the class selectedColInDataTable = colVar // var of the class if commandSelector == #selector(NSResponder.insertNewline(_:)) { doMovement(.return) return true } if commandSelector == #selector(NSResponder.cancelOperation(_:)) { doMovement(.cancel) return true } if commandSelector == #selector(NSResponder.moveDown(_:)) { doMovement(.down) return true } if commandSelector == #selector(NSResponder.moveUp(_:)) { doMovement(.up) return true } if commandSelector == #selector(NSResponder.insertTab(_:)) { doMovement(.tab) return true } if commandSelector == #selector(NSResponder.insertBacktab(_:)) { doMove
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’22
Reply to Implementing a cursor on both a cell and a row while using NSTableView
Yes you can. I implemented something similar in an app. nbIndividus is the number of rows, nbVariables is number of columns. selectedRowInDataTable and selectedColInDataTable are global var in the class. I just copy the code, you would have to adapt of course. func doMovement(_ mouvement: NSTextMovement) { if selectedRowInDataTable < 0 || selectedColInDataTable < 0 { return } var newRow = selectedRowInDataTable var newCol = selectedColInDataTable switch mouvement { // return as down case .return : newRow += 1 if newRow >= nbIndividus { newRow = nbIndividus - 1 ; playLightBeep() } case .tab : newCol += 1 if newCol >= nbVariables { newCol = 0 ; playLightBeep() } case .backtab : newCol -= 1 if newCol < 0 { newCol = nbVariables - 1 ; playLightBeep() } case .down: newRow += 1 if newRow >= nbIndividus { newRow = 0 ; playLightBeep() } case .up: newRow -= 1 if newRow < 0 { newRow = nbIndividus - 1 ; playLightBeep() } default: break } dataTableView?.selectRowIndexes([], byExtendingSelecti
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’22
Reply to App Crashes in iOS 16. Unable to find crash reason
But after symbolicating I found these runtime.mach_msg_trap + 36, runtime.mach_msg + 80. Wha!?! The second column of thread 4’s backtrace shows that these symbols are coming from Freshsales, you’re app’s Mach-O image. It sounds like you’re using third-party tooling that’s making system calls directly. This is not supported on any Apple platform. If you want to make a system call, you must call the relevant routine exported by libSystem. I recommend that you escalate this with the tool’s vendor. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com
Sep ’22
Reply to Why overlay is not on top
I think your problem is in the .padding(8) line. When you have that padding it adds 8px to all four external sides of the Text label, making it too small to fit the text on one line. You can achieve your desired look by reducing the font size, too, but that's probably not of much use. I've just put this into a new project, and Xcode is showing the preview in an iPhone 14 Pro (or Max) where the result is perfectly fine, because that device is quite wide. I've added .frame(width 380) to the ScrollView so it can be seen on a smaller screen. I've given the various elements a background colour so you can see where they interact: struct ContentView: View { var body: some View { ScrollView { LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible())]) { Stat() Stat() Stat() Stat() } } .frame(width: 380) // Change this to simulate smaller devices } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } struct Stat: View { var body: some View { VStack { Text(
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’22
UINavigationController inside UISplitViewController's UISplitViewControllerColumnSupplementary Doesn't Appear on Mac Catalyst
Working on a Mac Catalyst app. I have a UInavigationController. On iOS this is full screen but on Mac Catalyst I'm using it inside a UISplitViewController in the supplementary column. This view controller's root view controller has a navigationItem which configures a UISearchController. The search bar is nowhere to be found unless I set it to UINavigationItemSearchBarPlacementStacked. So is UINavigationItemSearchBarPlacementInline not supported for the supplementary column of a UISplitViewController? If that's the case I'm fine with that actually but there's got to be a way to make UINavigationItemSearchBarPlacementStacked look a little better on Mac? The search bar border is barely visible on a white background.
Replies
1
Boosts
0
Views
1.1k
Activity
Oct ’22
LazyHGrid Equal Distribution
Wish to ask for suggestions. My goal is to have a view where user inputs an array of strings. Depending on the number of strings, should have equal distribution of spacing between them. E.g. 5 items. 1st item should be top, last item should be bottom while the 2nd-4th should be in between and all of them should have equal spacing. This is what I have import SwiftUI struct MyView: View { @State private var labels: [String]? var labels = [Great, Major, Strong, Moderate, Small] var colors = [.blue, .red] HStack { Spacer() LazyHGrid(rows: [GridItem(.adaptive(minimum: 120))]) { if let labels { Group { ForEach(labels, id:.self) { label in Text(label) } } } } .frame(maxHeight: .infinity) Rectangle() .foregroundColor(.clear) .background(LinearGradient(gradient: Gradient(colors: colors ?? []), startPoint: .top, endPoint: .bottom)) Spacer() } } The result is not what I expected it to be. Notice the orange arrows. If i add more strings, [Great, Major, Strong, Moderate, Small, Great, Major, Strong, Moderate, Small], it b
Replies
1
Boosts
0
Views
482
Activity
Oct ’22
Making table header opaque to scrolling rows in SwiftUI
I am working on converting an application I wrote for iOS from using UIKit to using SwiftUI. So far, it looks like I’ve been able to get just about everything working with SwiftUI except for one thing. I have a table view that displays several rows of information in a few columns. The table has a single header at the top containing titles for each column. However, there is an aspect of the table view that introduced an undesirable behavior. When scrolling the content, row scrolling upward would appear underneath the header row. The desire was to have the header row be opaque with regard to the table content yet still allow background content underneath the header to show through. In UIKit I ended up implementing a hack of sorts to prevent content of scrolling rows from appearing directly behind the header. To do this, during scrolling the code was calling the UITableView.rectForHeader method and applying a mask to the layer of any rows that might be intersecting that header rectangle. That m
Replies
1
Boosts
0
Views
692
Activity
Oct ’22
Reply to Read a .dat file and plot a graph
Thanks a lot for your help. Could you recommend me some link where I can get more information about it ? I know exactly how many roll and columns my data file is and they are all composed by numbers from a double variable. Thanks again, Arthur.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to List is Disappearing
`struct ContentView: View { @Environment(.managedObjectContext) var moc @FetchRequest(sortDescriptors: [ SortDescriptor(.date) ]) var taxes: FetchedResults @State private var showingAddScreen = false // @EnvironmentObject var vm = ViewModel() @State var PDFUrls: URL? @State var showSheet: Bool = false @State private var selectedName: String? @State private var expanded: Bool = false let tax: Tax // @State private var items: [Any] = [] // @State private var sheet: Bool = false // let columns = [GridItem(.fixed(50)), GridItem(.fixed(50)), GridItem(.fixed(50)), GridItem(.fixed(50)), GridItem(.fixed(50))] var body: some View { // NavigationView { // VStack { VStack { HStack { // padding() EditButton() // .background(Color.yellow) .padding(.leading, 20) Spacer() Button { exportPDF { self } completion: { status, url in if let url = url, status { self.PDFUrls = url self.showSheet.toggle() } else { print(Failed to produce PDF) } } } label: { Image(systemName: square.and.arrow.up) //.background(Color.yellow)
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to Bug in StoreKit 2 in iOS 15.5-7
Hi, unfortunately this is an issue in Xcode 14.0. The issue is resolved in Xcode 14.1 RC, so if you build your app with that version it will be able to use these properties on iOS versions earlier than iOS 16.0. There is a workaround you can use to use these APIs in apps built with Xcode 14.0 and 14.0.1 listed in the Xcode 14.0 release notes, I'll quote it here: Using the following StoreKit properties and methods on apps with a minimum deployment target below iOS 16, macOS 13, watchOS 9, and tvOS 16 will cause the app to crash at launch when running on systems earlier than iOS 16, macOS 13, watchOS 9 and tvOS 16: priceFormatStyle and subscriptionPeriodFormatStyle on Product values environmentStringRepresentation and recentSubscriptionStartDate on Product.SubscriptionInfo.RenewalInfo values environmentStringRepresentation on Transaction values dateRange(referenceDate:) and formatted(_:referenceDate:) on Product.SubscriptionPeriod values (99962885) (FB11516463) Workaround: For each target using a StoreKit API l
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’22
Fit SwiftUI grid columns to the contents
My grids expand widthways to take up all the space it can. I can stick it in a frame and limit the size. But is there a way to get the columns to shrink to fit the contents plus padding? That would be neater, and probably more robust if the text changes size. FWIW most of my grids contain only text, and I don't use a lot of columns.
Replies
1
Boosts
0
Views
1.5k
Activity
Oct ’22
Reply to Passing an array into struct
Sorry this might be better than the previous post... var gameImport = 24,exam.dwindled.span,Short for examination,Reduced gradually in size,The total length of something from end to end,_ _ _ _ . _ w _ _ d _ _ d . _ _ _ n,16,///cracked.shadowed.private,The Vase was (?) when it toppled over,A part of the house is (?) by a tree every day,We like to talk in (?) when we want to keep it : secret,_ _ _ _ _ _ . _ _ _ _ _ _ . _ _ _ a t e,98,///spilling.dances.backbone,Causing or allowing liquid to flow over the edge : of its container,A series of steps that match the speed and : rhythm of a piece of music,The column of bones in the back which sustains : and gives firmness to the frame,_ p _ l l _ n . a _ c _ s._ a _ _ b _ n ,93,///inwards.habitat.buttered,Toward the centre or interior,Place where anything is commonly found,Covered or spread with butter, _ _ w _ r _ . a b t _ t._ u _ _ e _ e d, a e m x , d i l e n , p a s , d r a c c k e , d s a d o w e h , v r p i , g i s i , n d e , k o b c e , n s i a d ,
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to Passing an array into struct
Thank you for your time 🙏🏻 This is what I have done in Playgrounds... var printCards = // No required if NOT printing the cards // Imported .csv file pasted in (var gameImport) below //////////////// var gameImport = 24,exam.dwindled.span,Short for examination,Reduced gradually in size,The total length of something from end to end,_ _ _ _ . _ w _ _ d _ _ d . _ _ _ n,16,///cracked.shadowed.private,The Vase was (?) when it toppled over,A part of the house is (?) by a tree every day,We like to talk in (?) when we want to keep it : secret,_ _ _ _ _ _ . _ _ _ _ _ _ . _ _ _ a t e,98,///spilling.dances.backbone,Causing or allowing liquid to flow over the edge : of its container,A series of steps that match the speed and : rhythm of a piece of music,The column of bones in the back which sustains : and gives firmness to the frame,_ p _ l l _ n . a _ c _ s._ a _ _ b _ n ,93,///inwards.habitat.buttered,Toward the centre or interior,Place where anything is commonly found,Covered or spread with butter, _ _ w _
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’22
Develop In Swift Explorations - Unit 1 Build
In Part 1 of Unit 1 Build Students must set up the project using the App template feature. On page 55 the viewer window shows in the left column a list of files that should be in the photo frame. These include: AppDelegate, SceneDelegate, ViewController, Main, Assets and LaunchScreen. I can see this on my computer, however when my students follow the same steps. They only see the files name ad ContentView What are we doing wrong?!
Replies
3
Boosts
0
Views
818
Activity
Oct ’22
Reply to Implementing a cursor on both a cell and a row while using NSTableView
I forgot to show how to call this func: func control(_ control: NSControl, textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool { // 1. get row and column, multiplexed in sender's tag guard let textField = control as? TextField else { return false } let rowIndiv = textField.tag % (256 * 256) let colVar = (highWordTag - rowIndiv) / (256 * 256) selectedRowInDataTable = rowIndiv // a var of the class selectedColInDataTable = colVar // var of the class if commandSelector == #selector(NSResponder.insertNewline(_:)) { doMovement(.return) return true } if commandSelector == #selector(NSResponder.cancelOperation(_:)) { doMovement(.cancel) return true } if commandSelector == #selector(NSResponder.moveDown(_:)) { doMovement(.down) return true } if commandSelector == #selector(NSResponder.moveUp(_:)) { doMovement(.up) return true } if commandSelector == #selector(NSResponder.insertTab(_:)) { doMovement(.tab) return true } if commandSelector == #selector(NSResponder.insertBacktab(_:)) { doMove
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to Implementing a cursor on both a cell and a row while using NSTableView
Yes you can. I implemented something similar in an app. nbIndividus is the number of rows, nbVariables is number of columns. selectedRowInDataTable and selectedColInDataTable are global var in the class. I just copy the code, you would have to adapt of course. func doMovement(_ mouvement: NSTextMovement) { if selectedRowInDataTable < 0 || selectedColInDataTable < 0 { return } var newRow = selectedRowInDataTable var newCol = selectedColInDataTable switch mouvement { // return as down case .return : newRow += 1 if newRow >= nbIndividus { newRow = nbIndividus - 1 ; playLightBeep() } case .tab : newCol += 1 if newCol >= nbVariables { newCol = 0 ; playLightBeep() } case .backtab : newCol -= 1 if newCol < 0 { newCol = nbVariables - 1 ; playLightBeep() } case .down: newRow += 1 if newRow >= nbIndividus { newRow = 0 ; playLightBeep() } case .up: newRow -= 1 if newRow < 0 { newRow = nbIndividus - 1 ; playLightBeep() } default: break } dataTableView?.selectRowIndexes([], byExtendingSelecti
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to SwiftUI Table Limit of Columns?
I too am looking for > 10 columns (as well as the ability to edit cells). Any solutions would be appreciated.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to App Crashes in iOS 16. Unable to find crash reason
But after symbolicating I found these runtime.mach_msg_trap + 36, runtime.mach_msg + 80. Wha!?! The second column of thread 4’s backtrace shows that these symbols are coming from Freshsales, you’re app’s Mach-O image. It sounds like you’re using third-party tooling that’s making system calls directly. This is not supported on any Apple platform. If you want to make a system call, you must call the relevant routine exported by libSystem. I recommend that you escalate this with the tool’s vendor. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com
Replies
Boosts
Views
Activity
Sep ’22