Posts

Post marked as solved
1 Replies
122 Views
Lately, I keep getting this warning when closing Xcode asking if I want to save the changes. Strangely enough, I have never received this before. I looked to see if I could disable and enable autosave. Unfortunately I have not found anything. Does anyone have any tips?
Posted
by iRIG.
Last updated
.
Post not yet marked as solved
0 Replies
121 Views
My goal is to create Apples activity ring sparkle effect. So I found Paul Hudson's Vortex library. There is already a spark effect, but I don't know how to create a custom one that fits my needs. I'm still quite new to SwiftUI animations. Does someone have an idea how to do it? VortexView(createSparkle()) { Circle() .fill(.white) .frame(width: 16) .tag("circle") } func createSparkle() -> VortexSystem { let system = VortexSystem(tags: ["circle"]) system.birthRate = 150 system.emissionDuration = 0.2 system.idleDuration = 0.5 system.lifespan = 1.5 system.speed = 1.5 system.speedVariation = 0.2 system.angle = .degrees(330) system.angleRange = .degrees(30) system.acceleration = [0, 3] system.dampingFactor = 4 system.colors = .ramp(.white, .yellow, .yellow.opacity(0)) system.size = 0.1 system.sizeVariation = 0.1 system.stretchFactor = 8 return system } Vortex project: https://github.com/twostraws/Vortex
Posted
by iRIG.
Last updated
.
Post not yet marked as solved
1 Replies
219 Views
Hello everyone, How do I need to handle the delete with the relationship deny? When I delete a model that still has a reference to another model, it deletes it from the UI. But when I re-run the simulator, it's back again. Does someone have a hint for me? How is it possible to ensure the uniqueness of the entries? Because I saw that the Attribute unique can't be used with CloudKit.
Posted
by iRIG.
Last updated
.
Post not yet marked as solved
0 Replies
311 Views
I started playing around with the navigationDestination modifier. But currently it always re-routes me back to the list with the entries. Does someone have an idea why this happens? MainView NavigationStack { Form { Section { ProgressRing(percentage: $percentage) Text("1 of 3 compleatet") .font(.title2) .fontWeight(.medium) .foregroundStyle(Color.accentColor) } .listRowBackground(Color.clear) .listRowSeparator(.hidden) .frame(maxWidth: .infinity ,alignment: .center) .padding() Section("Daily tasks") { NavigationLink { EmptyView() } label: { Label("Log mood", systemImage: "seal") } NavigationLink { QuoteView() } label: { Label("Quote Gallery", systemImage: "seal") } NavigationLink { GratitudeListView() } label: { Label("Writing down gratitude", systemImage: "seal") } } } .navigationTitle("Hello, \(users.first?.name ?? "User")") } List { ForEach(gratitudes, id: \.self) { gratitude in NavigationLink(value: gratitude) { VStack(alignment: .leading) { Text(gratitude.gratitude1) Text(gratitude.createdAt, style: .date) } } } .navigationDestination(for: Gratitude.self, destination: { gratitude in GratitudeUpdateView(gratitude: gratitude) }) } .navigationTitle("Gratitude") .toolbar(.hidden, for: .tabBar) .overlay(alignment: .bottom) { NavigationLink { GratitudeAddView() } label: { PlusButton() } }
Posted
by iRIG.
Last updated
.
Post marked as solved
1 Replies
1.1k Views
Hello everyone, Is there a better solution than my approach out there to convert an image to data and back? @Model class User { var name: String @Attribute(.externalStorage) var image: Data? var createdAt: Date init(name: String, image: Data, createdAt: Date = .now) { self.name = name self.image = image self.createdAt = createdAt } } if let selectedPhotoData = imageData, let uiImage = UIImage(data: selectedPhotoData) { Image(uiImage: uiImage) .resizable() .scaledToFill() .frame(width: 300, height: 300, alignment: .center) .clipShape(Circle()) } .task(id: selectedPhoto) { if let data = try? await selectedPhoto?.loadTransferable(type: Data.self) { imageData = data } }
Posted
by iRIG.
Last updated
.
Post not yet marked as solved
2 Replies
799 Views
Hello together, I'm currently learning CoreData, but my preview in Xcode crashes always when I try to add something new to the view. Does someone have an idea what I need to pass to the preview that it works? My code
Posted
by iRIG.
Last updated
.
Post not yet marked as solved
0 Replies
640 Views
Hi everyone At the moment I try to use augmented reality QuickLook in Swift playgrounds When I try to open the reality file from the resource folder, this error shows up. Have someone an idea to fix that problem? Thanks in advance import QuickLook import RealityKit import ARKit struct ARQLViewController: UIViewControllerRepresentable {     func makeUIViewController(context: Context) -> some UIViewController {         return UINavigationController.init(rootViewController: ViewController())     }     func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {} } class ViewController: UIViewController, QLPreviewControllerDataSource {     var isAppeard: Bool = false     override func viewDidLoad() {         super.viewDidLoad()         DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {             let previewController = QLPreviewController()             previewController.dataSource = self             self.present(previewController, animated: true, completion: nil)         }     }    override func viewDidAppear(_ animated: Bool) {         guard !isAppeard else { return }         isAppeard = true         }     func numberOfPreviewItems(in controller: QLPreviewController) -> Int { return 1 }     func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {         guard let path = Bundle.main.path(forResource: "SipARAnimation", ofType: "reality") else { fatalError("Couldn't find the supported input file.") }         let url = URL(fileURLWithPath: path)         return url as QLPreviewItem     } }
Posted
by iRIG.
Last updated
.
Post not yet marked as solved
0 Replies
934 Views
Hello everyone, how can I change the standard pin icon to another? And how is it possible when I tap on the pin that an additional popup view opens in which the name of the city is at the top and that the associated image from the PhotoView is displayed? How could I best implement this? Thanks in advance MapView import MapKit import SwiftUI struct City: Identifiable {     let id = UUID()     let name: String     let coordinate: CLLocationCoordinate2D } struct MapView: View {     @State private var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 46.62407, longitude: 8.03434), span: MKCoordinateSpan(latitudeDelta: 0.1, longitudeDelta: 0.1))          let annotations = [         City(name: "Alte Strasse(Zuhause)", coordinate: CLLocationCoordinate2D(latitude: 46.63649, longitude: 7.97512)),         City(name: "Stalden1", coordinate: CLLocationCoordinate2D(latitude: 46.63937, longitude: 7.97216)),         City(name: "Stalden2", coordinate: CLLocationCoordinate2D(latitude: 46.63873, longitude: 7.96684)),         City(name: "Scheideggstrasse(Wetterhorn)1", coordinate: CLLocationCoordinate2D(latitude: 46.63353, longitude: 8.07356)),         City(name: "Scheideggstrasse(Wetterhorn)2", coordinate: CLLocationCoordinate2D(latitude: 46.63293, longitude: 8.07380)),         City(name: "Scheideggstrasse(Wetterhorn)3", coordinate: CLLocationCoordinate2D(latitude: 46.63313, longitude: 8.07329)),         City(name: "Scheideggstrasse(Wetterhorn)4", coordinate: CLLocationCoordinate2D(latitude: 46.63456, longitude: 8.07337)),         City(name: "Obere Gletscherstrasse(Wetterhorn)", coordinate: CLLocationCoordinate2D(latitude: 46.63205, longitude: 8.07022)),         City(name: "Obere Gletscherstrasse(Hotel Blümlisalp)", coordinate: CLLocationCoordinate2D(latitude: 46.63173, longitude: 8.06699)),         City(name: "Itramenstrasse", coordinate: CLLocationCoordinate2D(latitude: 46.62060, longitude: 7.99514))     ]     var body: some View {         Map(coordinateRegion: $region, annotationItems: annotations) {             MapMarker(coordinate: $0.coordinate)             }         .onAppear {             MKMapView.appearance().mapType = .satellite         }             }     struct MapView_Previews: PreviewProvider {         static var previews: some View {             MapView()         }     } } PhotoView struct ContentView: View {     var images: [String] = ["noaa1", "noaa2", "noaa3", "noaa4", "noaa5", "noaa6", "noaa7", "noaa8", "noaa9", "noaa10", "noaa11", "noaa12", "noaa13", "noaa14", "noaa15", "noaa16", "noaa17", "noaa18"]          var columnGrid: [GridItem] = [GridItem(.fixed(180), spacing: 16), GridItem(.fixed(180), spacing: 16)]              var body: some View {         NavigationView {             ScrollView {                 LazyVGrid(columns: columnGrid, alignment: .center, spacing: 16) {                     ForEach(images, id: \.self) { image in                         NavigationLink (destination: ImageDetail(imageName: image)) {                             Image(image)                                 .resizable()                                 .scaledToFit()                                 .cornerRadius(10)                         }                     }                 }             }.navigationBarTitle(Text("Test"), displayMode: .inline)         }.navigationViewStyle(.stack)     } }
Posted
by iRIG.
Last updated
.
Post not yet marked as solved
1 Replies
1.1k Views
Hello, I struggling to integrate this code below in my Content View can someone give me help? import UIKit import QuickLook import ARKit class ViewController: UIViewController, QLPreviewControllerDataSource {     override func viewDidAppear(_ animated: Bool) {         let previewController = QLPreviewController()         previewController.dataSource = self         present(previewController, animated: true, completion: nil)     }     func numberOfPreviewItems(in controller: QLPreviewController) -> Int { return 1 }     func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {         guard let path = Bundle.main.path(forResource: "myScene", ofType: "reality") else { fatalError("Couldn't find the supported input file.") }         let url = URL(fileURLWithPath: path)         return url as QLPreviewItem     } }
Posted
by iRIG.
Last updated
.
Post not yet marked as solved
0 Replies
780 Views
Hello, I want to implement AR quick look to my app. I' don't want to use UIKit but SwiftUI. In one of my views, I want to press a button named "preview" and then it should open the AR quick look. Have someone an idea how I can do that? Sorry for that badly formatted code below. import UIKit import QuickLook import ARKit class ViewController: UIViewController, QLPreviewControllerDataSource { override func viewDidAppear(_ animated: Bool) { let previewController = QLPreviewController() previewController.dataSource = self present(previewController, animated: true, completion: nil) } func numberOfPreviewItems(in controller: QLPreviewController) -> Int { return 1 } func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem { guard let path = Bundle.main.path(forResource: "myScene", ofType: "reality") else { fatalError("Couldn't find the supported input file.") } let url = URL(fileURLWithPath: path) return url as QLPreviewItem } } [https://developer.apple.com/documentation/arkit/previewing_a_model_with_ar_quick_look)
Posted
by iRIG.
Last updated
.
Post marked as solved
1 Replies
776 Views
Hello, how can I turn this standard map view into a Satellite map view? Thanks //  MapView.swift //  Grindelwald View // //  Created by Roman Indermühle on 15.04.22. // import MapKit import SwiftUI struct City: Identifiable {     let id = UUID()     let name: String     let coordinate: CLLocationCoordinate2D } struct MapView: View {          @State private var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 46.62407, longitude: 8.03434), span: MKCoordinateSpan(latitudeDelta: 0.17, longitudeDelta: 0.17))               let annotations = [         City(name: "Burglauenen", coordinate: CLLocationCoordinate2D(latitude: 46.63649, longitude: 7.97512)),         City(name: "Stalden", coordinate: CLLocationCoordinate2D(latitude: 46.63937, longitude: 7.97216)),         City(name: "Stalden2", coordinate: CLLocationCoordinate2D(latitude: 46.63873, longitude: 7.96684))                       ]               var body: some View {         Map(coordinateRegion: $region, annotationItems: annotations) {             MapMarker(coordinate: $0.coordinate)                                   }                       }      } struct MapView_Previews: PreviewProvider {     static var previews: some View {         MapView()     } }
Posted
by iRIG.
Last updated
.
Post marked as solved
1 Replies
883 Views
Hello, how can I add a detail view to this code? I want to show the image in a detail view and that for every image single. import SwiftUI struct ContentView: View {     var images: [String] = ["noaa1", "noaa2", "noaa3", "noaa4", "noaa5", "noaa6", "noaa7", "noaa8", "noaa9", "noaa10", "noaa11", "noaa12", "noaa13", "noaa14", "noaa15", "noaa16", "noaa17", "noaa18"]          var columnGrid: [GridItem] = [GridItem(.flexible()), GridItem(.flexible())]          var body: some View {             ScrollView {                 LazyVGrid(columns: columnGrid) {                     ForEach(images, id: \.self) { image in                         Image(image)                             .resizable()                             .scaledToFit()                             .cornerRadius(10)                                      }             }         }     }          struct ContentView_Previews: PreviewProvider {         static var previews: some View {             ContentView()         }     } }
Posted
by iRIG.
Last updated
.
Post not yet marked as solved
1 Replies
721 Views
Hi everyone, does anyone have a suggestion on how I can add a detail view to this grid view? import SwiftUI struct ContentView: View {     var body: some View {         NavigationView {             List {                 ImageRow()             }.navigationBarTitle(Text("Landscapes"))         }     } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView()     } } import SwiftUI import Combine struct ImageRow: View {     var body: some View {         var images: [[Int]] = [] _ = (1...18).publisher .collect(2) // Creating two columns             .collect()             .sink(receiveValue: { images = $0 })                  return ForEach(0..<images.count, id: \.self) { array in             HStack {                 ForEach(images[array], id: \.self) { number in                     Image("noaa\(number)")                         .resizable()                         .scaledToFit()                         .cornerRadius(10)                   }             }         }     } }
Posted
by iRIG.
Last updated
.