Search results for

column

2,046 results found

Post

Replies

Boosts

Views

Activity

Reply to swipeActions on macOS?
Even with two columns and a Label. It does not work for me. I am using Xcode 14 and Monterey var body: some View { VStack { List(podcast.episodes!) { episode in EpisodeView(podcast: podcast, episode: episode) .swipeActions(edge: .trailing) { Button (action: { self.deleteEpisode(episode) }) { Label(Delete, systemImage: trash) } .tint(.red) } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’22
Reply to SwiftUI MacOS TableColumn compiler can't type-check expression in reasonable time.
I found this problem as well. My solution is not very elegant, I'm afriad. I had to be very specific about the types. I moved the columns into their own @TableColumnBuilder with all the generics specified: @TableColumnBuilder private var columns: TupleTableColumnContent< Weather.State.Row, Never, ( TableColumn, TableColumn, TableColumn, TableColumn, TableColumn, TableColumn ) > { TableColumn(Local Date/Time, value: .dateTime) TableColumn(Temperature, value: .temp) TableColumn(Apparent Temperature, value: .apparentTemp) TableColumn(Dew Point, value: .dewPoint) TableColumn(Humidity, value: .humidity) TableColumn(Rain, value: .rain) } Though this is a lot of ugly specificity, it's the type inference that slowing Swift down here. I was lucky because I don't need a sort comparator (hence the Never above) and all my labels and views are simply Texts. There may be a way to clean this up further with buildPartialBlock
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’22
Error Domain=NSCocoaErrorDomain Code=3840 AND
Hello, I have a problem when I launch the application I have this error displayed in the log of the swift: Error Domain=NSCocoaErrorDomain Code=3840 JSON text did not have any content around line 2, column 0. UserInfo={NSDebugDescription=JSON text did not have any content around line 2, column 0., NSJSONSerializationErrorIndex=1} here is the php : set_charset(utf8mb4); // Check connection if (mysqli_connect_errno()) { echo Failed to connect to MySQL: . mysqli_connect_error(); } // This SQL statement selects ALL from the table 'Locations' $sql = SELECT `id`,`nom`,`prenom`,`tel`,`email`,`mdp`,`adr`,`cp`,`ville` FROM clients; // Check if there are results if ($result = mysqli_query($con, $sql)) { // If so, then create a results array and a temporary one // to hold the data $resultArray = array(); $tempArray = array(); // Loop through each row in the result set while($row = $result->fetch_object()) { // Add each row into our results array $tempArray = $row; array_push($resultArray, $tempArra
5
0
1.7k
Nov ’22
Reply to Error Domain=NSCocoaErrorDomain Code=3840 AND
my bad i forgot my code : import Foundation import UIKit protocol HomeModelDelegate { func itemsDowloaded(client:[Client] ) } class HomeModel : NSObject { var delegate:HomeModelDelegate? func getItems(){ //Hit the conn url let serviceURL = http://myFTPSERVER/service.php //Download the JSON Data let url = URL(string: serviceURL) if let url = url { // Create a URL Session let session = URLSession(configuration: .default) let task = session.dataTask(with: url) { (data, url, error) in if let data = data { //Succed print(data) //call the parseJson self.parseJson(data) }else{ } } // Start the task task.resume() } //notify the view controller and pass the data back } func parseJson(_ data:Data){ var clientArray = [Client]() do { //Parse the data into Client structs let jsonArray = try JSONSerialization.jsonObject(with: data, options: []) as! [Any] print(jsonArray) //loop through each result in the json array for jsonResult in jsonArray { //Cast json result as a dictionary let jsonDict = jsonResult as! [String:String
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’22
How to add an IBAction to a macOS tableView Cell
I have a macOS tableview I have a textfield as a column along with an IBAction code to capture the data from this field. I wanted to add continuous spell check for this column . So, I decided to change the column from a TextField to a ScrollView to take advantage of the continuous spell check. Using Xcode 14 I changed the Cell to a custom Cell. The custom cell has a scrollview object as the object because I want to take advantage of the built in continuous spell checking instead of using a textfield. All is well with this implementation until I tried to add a IBAction code for when I enter text in the scrollview/textView field. There does not seem to be a way to capture the text? Am I trying to do something that can't be done or is there a way to add continuous spell check to a textField?
4
0
1.4k
Nov ’22
Reply to How to add an IBAction to a macOS tableView Cell
To get access from the VC, you should, in the VC: create an IBOutlet for the tableView (not its container ScrollView) get a reference to the cell, with something like (adapt row and column values) guard let cell = tableView.view(atColumn: 0, row: 0, makeIfNecessary: true) as? CustomTableCell else { return } then use the cell to access any component you need: let text = cell.testTextView.textStorage?.string
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’22
Mac Catalyst: UINavigationController incorrectly blocks -setViewControllers:animated: call on UINavigationController when a transition/presentation is occurring on a different view controller.
I have a triple UISplitViewController. A UINavigationController is in the secondary column. When the selection changes in the supplementary column I call -setViewControllers:animated: and pass the navigation controller the new vc. I noticed sometimes the navigation view controller isn't updating and this logs out: setViewControllers:animated: called on while an existing transition or presentation is occurring; the navigation stack will not be updated. So this happens when the Split View controller itself is presenting another view controller modally (say a view controller with a UIActivityIndicatorView in it to show loading progress). But there is no transition/presentation occurring on the UINavigationController contained in the secondary view controller column itself. The presentation occurring on the UISplitViewController is completely separate and unrelated to the UINavigationController's navigation stack that's in the secondary column and therefore I should not be prev
1
0
763
Nov ’22
Reply to NavigationSplitView No Toggle Button
Why is there no toggle button above? What do you mean by toggle button? Do you mean the button that hides and shows the sidebar? This is only present when the horizontalSizeClass is .regular. On an iPhone in portrait mode, it won't appear. ‎ And why is the menu always showing? What menu are you talking about? ‎ I cant see the detiail view anymore If you want to see the detail view, you need to select an item from the list. As I said before, the two-column layout with the sidebar toggle button is only present when the horizontalSizeClass is .regular. In your screenshot (an iPhone in portrait mode) the NavigationSplitView collapses down to a single column layout and acts more like a NavigationStack.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’22
NavigationSplitView No Toggle Button
I went back to square one since the NavigationLink isActive is deprecated, this is when I found out about NavigationSplitView which removes the hassle of creating a 2 column app. However, I can never figure out why the toggle button does not show. I copied this sample code (already tried 2 tutorials, copy pasted them but still no toggle button) Anyone know why? import SwiftUI enum DemoScreen: String, Codable { case first, second, third var title: String { rawValue.capitalized } } struct ContentView: View { @State private var selection: DemoScreen? = .first var body: some View { NavigationSplitView { sidebarContent } detail: { detailContent } } } extension ContentView { var sidebarContent: some View { List { link(to: .first) link(to: .second) link(to: .third) } } func link(to page: DemoScreen) -> some View { NavigationLink(value: page) { Text(page.title) } } } extension ContentView { @ViewBuilder var detailContent: some View { if let selection = selection { detailContent(for: selection) .buttonStyl
1
0
899
Nov ’22
Mac Catalyst: UISplitViewControllerColumnSecondary doesn't get key focus when the Tab Key is Pressed in a Triple UISplitViewController.
My UISplitViewController is configured like this: A list (collection view) is used in the primary view controller (sidebar style). When a selection is made in the primary view controller a table view displays data in the supplementary column. When a selection is made in the supplementary view controller, a view controller with scrollable content is shown in the secondary view controller. This is like the Mail app on Mac. So when I run the app I hit the tab key once and the list (collection view) in the primary column gets focus. I can navigate the list with the keyboard. This works as expected. So now with a selection in the list, a table view is showing in the supplementary column. I hit the tab key again and the table view gets focus. This works as expected as I can navigate the table view from the keyboard with the arrow keys. Now with a selection made in the table view, the scrollable view controller is showing in the secondary view controller column. I hit the tab key
3
0
889
Nov ’22
How to fix these errors?
Hello there! I want to create a cards game, and I'm creating it following the Stanford University's tutorial. I followed the video step by step but there is a warning that In the video doesn't appear. Can someone help me to fix it? Here's the link of the video: [https://www.youtube.com/watch?v=oWZOFSYS5GE&t=671s) This is my code: import SwiftUI struct ContentView: View { var emojis =[🚲,🚂,🚁,🚜,🚕,🏎,🚑,🚓,🚒,🚁,🚀,⛵️,🛸,🛶,🚌,🛺,🚇,🚠,🦽,🚗,🚚,🛴,🛵,🚅] @State var emojiCount: Int = 4 var body: some View { ScrollView { LazyVGrid(columns: [GridItem(), GridItem(), GridItem()]) { HStack { ForEach(emojis[0.. 1 { // here's the first error which says Cannot find 'emojiCount' in scope' emojiCount -= 1 // here's the same error which says Cannot find 'emojiCount' in scope' } } label: { Image(systemName: minus.circle) } } var add: some View { Button { if emojiCount < emojis.count { // here's the same error which says Cannot find 'emojiCount' in scope' emojiCount += 1 // here's the same error which says
4
0
597
Oct ’22
Reply to How to fix these errors?
Do you mean those warnings ? if emojiCount > 1 { // here's the first error which says Cannot find 'emojiCount' in scope' emojiCount -= 1 // here's the same error which says Cannot find 'emojiCount' in scope' } You're new to the forum, so welcome. And get a few advices: You'd better expose error messages clearly and not let others search for them in code… when you post code to avoid leaving 20 blank lines… Use Paste and Match Style and then code formatter tool. That will make your code easier to read. I noted several errors: var emojis = [🚲,🚂,🚁,🚜,🚕,🏎,🚑,🚓,🚒,🚁,🚀,⛵️,🛸,🛶,🚌,🛺,🚇,🚠,🦽,🚗,🚚,🛴,🛵,🚅] There need a space after =before [ var remove: some View { is defined out of struct ContentView: View { Hence, @State var emojiCount is not visible out of its scope (the struct). Probably, you have a misplaced closing parenthesis. This should be correct: import SwiftUI struct ContentView: View { var emojis = [🚲,🚂,🚁,🚜,🚕,🏎,🚑,🚓,🚒,🚁,🚀,⛵️,🛸,🛶,🚌,🛺,🚇,🚠,🦽,🚗,🚚,🛴,🛵,🚅] @State var emojiCoun
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’22
Reply to Anchor on Sky? (Yea the clear blue sky)
Yes. You can add your own anchor to the session: https://developer.apple.com/documentation/arkit/arsession/2865612-add To instantiate your own anchor, you can call the anchor initializer with a 4x4 transform: https://developer.apple.com/documentation/arkit/aranchor/2867985-init . Elevation of the space ship in meters above the ground would be the 3rd element in the fourth column of the transform.
Topic: Spatial Computing SubTopic: ARKit Tags:
Oct ’22
Why overlay is not on top
Please see image. I want the text one case per million to extend. but in this scenario, it seems that the image overlay is occupying space inside the the view where the text are located Same as One Death Per People. I think the first line should be One Death Per and maybe because the image is big that it somehow is occupying its area? (But i placed the image in overlay so it should be rendered no top) I think the word Per should still in in the first line. Any idea what could be the problem? This is my code struct Stat: View { var body: some View { VStack { Text(One Case Per People) .frame(maxWidth: .infinity, alignment: .leading) .font(.system(size: 19)) Text(2) .frame(maxWidth: .infinity, alignment: .leading) .font(.system(size: 15)) Spacer() } .padding(8) .frame(minHeight: 100) .cornerRadius(8) .background(Color.gray) .overlay( Image(systemName: person.3.fill) .resizable() .frame(width: 60, height: 60, alignment: .trailing) .padding(8), alignment: .bottomTrailing ) } } I used a grid to display them ScrollV
4
0
1.5k
Oct ’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:
Oct ’22