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
}
}
Post
Replies
Boosts
Views
Activity
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)
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()
}
}
}
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()
}
}
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)
}
}
}
}
}
I will briefly explain my view. My goal is to make a list where you can enter all personal information like a kind of emergency passport. There should also be text fields where you can tap on the plus button and then there is a new text field. On the top right I want to make an edit button that you can delete text fields again. I will connect this view with another SwiftUI view file. Does anyone have an idea how to solve this problem with the list?
import SwiftUI
struct ListeDaten: Identifiable {
let id = UUID()
let Name: String
let Adresse: String
var Telefonnummern: [String] = []
var Something: String = ""
}
struct ListeDaten: View {
var body: some View {
TextField(Name: "Name/Vorname")
TextField(Adresse: "Adresse")
ForEach(id: \.self) {Telefonnummern in TextField("Telefonnummer")}
Button(action: {
Telefonnummern.append("")
})
{
Image(systemName: "plus.circle.fill")
.foregroundColor(Color(.systemGreen))
}
}
}
struct ListeDaten_Previews: PreviewProvider {
static var previews: some View {
ListeDaten()
}
}
Good day, I would like to generate a text field when I tap on the green button that creates a new text field and I can still enter for example a 2nd phone number. I have already tried it with this example:
Button(action: { print("Telefonnummer")}) {
Image(systemName: "plus.circle.fill")
.foregroundColor(Color(.systemGreen))
}
Good day, I have the problem that when I switch from one view to another, the content is moved to the bottom every time. I have already tried with the: See picture attached:
[https://we.tl/t-SUYZZh6M2P)
Does anyone have a solution suggestion?
Greetings