Post

Replies

Boosts

Views

Activity

Reply to SwiftUI NavigationLink isActive is not working right on iOS 14.5
this code should run well before iOS 14.5.  Can you clarify what you think is well? As far as I tried both with iOS 14.4 simulator of Xcode 12.4 and iOS 14.5 simulator of 12.5, your code behaves exactly the same: When you tap the link, the destination is shown. (And isActive gets true.) What do you expect for isActive? Aren't you confused with isActive and sort of disabled(_:)? Or am I misinterpreting what you mean? More than two NavigationLinks in List makes me very depressed. Can you show a complete code with enough description what you expect?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to Data not passing correctly - SwiftUI, CoreData
Having multiple sheets controlled by a single @State variable is not recommended. Please try something like this: struct ItemsView: View { @Environment(\.managedObjectContext) private var viewContext @ObservedObject var group: ItemGroup @State private var showingDetailView = false @State var selectedItem: Item = Item() var body: some View { ScrollView { VStack(alignment: .leading) { ForEach(group.ongoingItems) { item in itemRow(for: item) .padding() } //... } //... } .sheet(isPresented: $showingDetailView, content: { ItemInfoSheet(item: $selectedItem) }) } func itemRow(for item: Item) - some View { HStack(spacing: 10) { //... Text(item.wrappedName) .fontWeight(.light) Spacer() Button(action: { selectedItem = item showingDetailView.toggle() }, label: { Image(systemName: "info.circle").imageScale(.large) }) } } //... } struct ItemInfoSheet: View { @Binding var item: Item var body: some View { NavigationView { ItemDetailView(selectedItem: item) } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to Error loading Storyboard
It is a different project, a new project that I created with no additions, I just created a new project, went straight to storyboard and bam, the issue was there already. I created a new project, opened the Main.storyboard with text editor and replaced the content with the XML you have shown. I then re-opened the project with Xcode 12.5, nothing happens. Opened Main.storyboard and Interface Builder opened without any problems. Ran the app, and the simulator started without any issues. I'm afraid your Mac environment might be broken. Have you upgraded your Mac from an older version? If so, there may be some remains of old Xcode tools or intermediate builds in your Mac.
May ’21
Reply to Error loading Storyboard
How do I go about fixing the Mac environment in case it is broken which it most likely is?  Hard to say something sure. There may be many parts where Xcode would store intermediate something. But, for example, in my Mac using Xcode, there is no directory /Library/Caches/com.apple.xbs. You may need to find all such directories and try removing them. (Of course, you should better make backups before trying.)
May ’21
Reply to In SwiftUI I would like to declare an @ObservedObject var with a type defined in a protocol...
To declare an @ObservedObject var, you need a type conforming to ObservableObject. The protocol GalleryDataSource does inherit ObservableObject, but does not conform to ObservableObject. Currently, there is no way provided to make protocols to conform some other protocol in Swift. Better find another way. One possible alternative would be using generics: struct GalleryViewDataSource: GalleryDataSource: View { @ObservedObject var dataSource: DataSource var body: some View { ScrollView(.horizontal, content: { HStack { ForEach(0..self.dataSource.itemCount, id:\.self) { index in Text(dataSource.item(for: index)) .padding() } } }) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to Location permission dialog disappears after 1 second
I tried your code, filling many missing parts by guess, and could not reproduce the issue. The dialog was kept showing until I tapped Allow Once. You may have too simplified your code and something you have not shown is affecting. It is hard to say anything sure, but have you tried using @StateObject instead of @ObservedObject?:     @StateObject var locationManager = LocationManager()
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to Navigation Link - presentationMode.Dismiss problem XCode 12.5
Thanks for showing the new code. I tried it both with Xcode 12.4 and 12.5, and only in case of 12.5, I could see Unable to present. Please file a bug.. But as far as I tried, the app continued working and the message seemed not causing severe damage to the app. I'm not sure, but this message may be ignored as a sort of log noise. Or have you experienced something critical with your app? (Some older report with Unable to present. Please file a bug. said that the subviews closed immediately after the message without touching cancel, I think this is not the case as yours.) When I find something useful about this issue, I will share it. By the way, you have mistakenly marked my previous reply as the solution, which I believe is not. As you have noticed, you cannot unmark it (one bad thing with this site). Unfortunately, SOLVED threads would not be appealing and get less attention from readers. In case you have something critical which needs to be fixed, you should better start a new thread. (Please be careful not to mark it as SOLVED mistakenly.) You should use the Code block (icon ``) when you show some code, easily readable would also affect involving more readers into this issue.
May ’21
Reply to What is a scope ?
And I receive the following error "Cannot find 'HexagonParameters' in scope" How do I code the the scope for HexagonParameters ? I guess you took the code from a tutorial of SwiftUI and HexagonParameters is a name of a struct. In this case, scope is somewhere in your project. You create a new file named HexagonParameters.swift in your project and put the definition of it into the file. https://developer.apple.com/tutorials/swiftui/drawing-paths-and-shapes
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Refresh value in text label from JSON
I can't see it reflected in my app. What do you see instead? As far as I tried your code, the NSTextField itemSalida showed -1, which seems to be the expected value. (I needed to simulate URLSession as I cannot access 192.168.0.15:8080, to fill JSONAny and to correct the JSON text by adding [ and ].) I know that I must perform a function to refresh the data What do you think you must? Your code is enough to update the content of the label. if those values are updated, my app does not show them When or where are those values updated? Other than your loadData?
May ’21