Greetings, I'm just learning Swift language by Playgrounds and some Udemy educations. I have a problem with Coding 2 - Connect and Solve episode. I supposed to build 3 - 2 - 3 blocks to three spots on 2nd column BUT blocks are acting like ghosting, it appears like for 0.5 seconds and disappear again. Then only change that I made is updating MacOS system with the lastest patch. Open to any ideas about the issue. Tnank you!
Search results for
column
2,052 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I have a LazyVGrid, every item with is favorite button. and use combine to debounce user input($isFavoriteI), when isFavoriteO changed, then modify the items. it works fine, but when i scroll the list, log will print: X, isFavorite changed as false/true), what cause isFavoriteO changed and why? because of item reusing in list? how to avoid it? index 7, isFavorite changed as true index 7, isFavorite changed as true index 7, isFavorite changed as true index 7, isFavorite changed as true index 7, isFavorite changed as true index 7, isFavorite changed as true index 7, isFavorite changed as true index 7, isFavorite changed as true import SwiftUI import Combine struct Item { var index: Int var favorite: Bool } var items = [ Item(index: 0, favorite: true), Item(index: 1, favorite: false), Item(index: 2, favorite: true), Item(index: 3, favorite: false), Item(index: 4, favorite: true), Item(index: 5, favorite: false), Item(index: 6, favorite: true), Item(index: 7, favorite: false), // Item(index: 8, favorite: true), /
I feel weird replying to my own post, but since no one else has replied, I'm going to seed this with another example of why developers want this. While my above example uses a two column grid, another common use case is a collection view containing a section with an orthogonal scroll direction, and a series of items with potentially different heights (self-sizing for the win, right?). Think: Horizontally scrolling carousel of cards. It's easy to force the height of this carousel and its items to some fixed height, but we don't want that. We want the content to self-size and the height to be a function of that. That's also easy if we don't care about the vertical alignment of the items, or requiring the items to share the height of the tallest item. Here's a visual aid: How can we leverage self-sizing, but then additional require that all of the items in the group must share the height of the tallest item? In a more general sense, you can think of this as an alignment issue. How do you leverage self-s
Topic:
UI Frameworks
SubTopic:
UIKit
Tags:
I have a custom Instrument with a os-signpost-interval-schema that captures a state string. I would like the final plot value to be : , but I don't know how to get the duration into the string. My working schema is the following, which just stores the state itself in the column: state-interval State Interval ... ... state ?state state State string ?state I would like to change the expression in the column to (str-cat ?state : ?duration), but that fails with: Variable '?duration' must appear in a pattern element to be used in a later expression. I don't see any way to compute this later in the graph, lane, or plot. I've also tried explicitly creating a , but that doesn't seem to change anything. The rest of the pieces include the table: state-table state-interval And the lane, which I would like to display as : rather than just the duration: State state-table state
I have a follow up question. I have not implemented the BNNS approach proposed above and it works. However, the calculation speed is still about 3 times as high when I use a similar approach in Python - without any particular special packages or approaches on Python side. I was hoping that Swift would generally be faster so wanted to get your view on whether maybe my approach is generally flawed and her any potential alternatives. I would love to continue with coding in Swift on the project but with runtime being 300% it is just too compelling to rather use Python. Let me explain what I am doing: I create a lot of (random) binary trees which contain arithmetic or logic operations in all non-leaf nodes and numeric arrays (all of the same length) on leaf nodes which are taken from return_data. I.e. my trees are representing (simple) mathematic formulas. I have tens of thousands such trees and need to efficiently evaluate them. I currently do this via a recursive function evaluate_signal. As said above, the same
Topic:
Programming Languages
SubTopic:
Swift
Tags:
Yes sorry, I'm using MacOS 13.0.1 - Xcode 14.1 I'm basically trying to mimic the finder column view. So, to have multiple Lists that are horizontally aligned. If there is too many List for the window size, then I can scroll horizontally. When I use VStack instead of List/ScrollView, it works perfectly. When I use List/ScrollView, if the cursor is over the nested List/ScrollView, the horizontal scroll lags. But if the cursor is next to the nested List/ScrollView, the horizontal scroll works fine. Here is a video that shows the issue. https://www.youtube.com/watch?v=_UdlNZQH6Pg
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
I'm trying to reproduce in a way the finder column view, but I'm facing an issue. A scroll conflict occurs when I put a ScrollView or a List inside another ScrollView. The horizontal scroll is lagging when the cursor is over the nested ScrollView. Here is my simplified code: struct SplitView: View { var body: some View { ScrollView(.horizontal, showsIndicators: false){ HSplitView{ ScrollView(showsIndicators: false) { VStack(alignment: .leading) { ForEach(0..<100) { Text(Row ($0)) } }.frame(minWidth: 200, alignment: .leading) } ScrollView { VStack(alignment: .leading) { ForEach(0..<100) { Text(Row ($0)) } }.frame(minWidth: 200, alignment: .leading) } ScrollView { VStack(alignment: .leading) { ForEach(0..<100) { Text(Row ($0)) } }.frame(minWidth: 200, alignment: .leading) } } } } } I have the same issue with nested List. Do you have any idea how I can prevent that? Or any workaround?
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:
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:
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
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:
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?
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:
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
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