How do I overlay an annotation/detail popup to AR Models in QuickLook? This was done with the WWDC Trading Cards AR Model. I haven't been able to find any other info on this. Here is an article which has an image of what I am referring to
https://vrscout.com/news/apple-shows-off-ar-trading-cards-ahead-of-wwdc-2022/
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I want to add a small banner to my AR model when viewed in QuickLook in my app. I haven't been able to find much information on this however I found this resource where it explains how to add it when you have a model on a website. My model is locally stored on the device so how would I add this?
In my collection view I have an image with some text below. I have a height constraint for the image view so the image aspect ratio can be adjusted (cells are the width of the screen). I set the constraint constant in cellForItemAt. The cell heights only resize correctly after I scroll.
CollectionViewController
override func viewDidLoad(_ animated: Bool) {
super.viewDidLoad(animated)
let layout = collectionView.collectionViewLayout
if let flowLayout = layout as? UICollectionViewFlowLayout {
flowLayout.estimatedItemSize = CGSize(width: collectionView.widestCellWidth, height: 800)
}
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! selectCell
cell.setupView()
// Image resolution is already downloaded
let gsReference = storage.reference(forURL: thumbnail.storageLocation)
cell.imageView.sd_setImage(with: gsReference, placeholderImage: nil)
cell.layoutIfNeeded()
cell.layoutSubviews()
return cell
}
selectCell.swift
override func systemLayoutSizeFitting(_ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -> CGSize {
var targetSize = targetSize
targetSize.height = CGFloat.greatestFiniteMagnitude
let size = super.systemLayoutSizeFitting(targetSize, withHorizontalFittingPriority: .required, verticalFittingPriority: .fittingSizeLevel)
return size
}
func setupView() {
// Changing the labels size the cell correctly when first loaded
titleLbl.text = ""
descriptionLbl.text = ""
let imageAspectRatio = CGFloat(metadata.thumbnail.width) / CGFloat(metadata.thumbnail.height)
let imageViewHeight = containerView.frame.width / imageAspectRatio
imageViewHeightConstraint.constant = imageViewHeight
self.contentView.setNeedsLayout()
self.contentView.layoutIfNeeded()
}
I’m trying to add a search filter UI like the one used in the Music app. I’ve tried to add a reusable view to the search controller collection view but there seems to be padding around it. My plan was just to add a Collection View there and try recreate the animation used.
I tried scope buttons but those are a segment control, so they only hold a few options.
In my view controller I have a collection view and over that there is a scroll view (covering the whole main view). The collection view acts as a sort of "header" to the scroll view and has images in it. The scrollview has a clear view at the top the same size as the collection view to make the collection view visible through the scrollview - collectionViewTouchView. This is done so I can create a parallax effect when scrolling.
The problem is that I can't swipe on the collection view because the scrollview is over it. Can I somehow record touch events on collectionViewTouchView and then pass it directly to the collection view?
In my app user accounts are handled with Firebase Auth. When creating a user how can I get the system to suggest a Unique password (that prompt that comes up on the keyboard) and also how can i get it to save these details to the keychain. My app will have a website in the future so I want the details come up when the user tries to login there.
When the user logs in i used the func below to save the details to the keychain, it says the details have been saved but it doesnt seem to come up in the passwords tab in Settings.
func saveCredentialsToKeychain(email: String, password: String) {
let query: [String: Any] = [
kSecClass as String: kSecClassInternetPassword,
kSecAttrServer as String: "myWebsite.com",
kSecAttrAccount as String: email,
kSecValueData as String: password.data(using: .utf8)!,
kSecAttrAccessible as String: kSecAttrAccessibleWhenUnlocked
]
let status = SecItemAdd(query as CFDictionary, nil)
if status == errSecSuccess {
print("Credentials saved to Keychain")
} else {
print("Error saving credentials to Keychain: \(status)")
}
}
I have a CollectionView in my SwiftUI App. The collectionView is wrapped in a UIViewRepresentable. If I tap on a collectionView cell normally the function isn't called but if I hold the cell down the console prints <0x107507790> Gesture: System gesture gate timed out. and when I let go of the cell after that's printed then didSelectItem is called.
Here is my CollectionView Class:
class SessionsCollectionView: UIView, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
lazy var collectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout()
layout.minimumInteritemSpacing = 0
layout.minimumLineSpacing = 30
let collectionView = UICollectionView(frame: CGRect.zero, collectionViewLayout: layout)
collectionView.translatesAutoresizingMaskIntoConstraints = false
collectionView.dataSource = self
collectionView.delegate = self
collectionView.clipsToBounds = false
collectionView.delaysContentTouches = false
collectionView.register(SessionCell.self, forCellWithReuseIdentifier: "cell")
collectionView.register(SessionsHeader.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "header")
return collectionView
}()
override init(frame: CGRect) {
super.init(frame: frame)
self.backgroundColor = .clear
setupCollectionView()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func setupCollectionView() {
addSubview(collectionView)
collectionView.backgroundColor = .clear
collectionView.alwaysBounceVertical = true
collectionView.alwaysBounceHorizontal = false
collectionView.delaysContentTouches = false
collectionView.contentInset = .init(top: 20, left: 0, bottom: 20, right: 0)
collectionView.showsVerticalScrollIndicator = false
NSLayoutConstraint.activate([
collectionView.topAnchor.constraint(equalTo: topAnchor),
collectionView.leadingAnchor.constraint(equalTo: leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: trailingAnchor),
collectionView.bottomAnchor.constraint(equalTo: bottomAnchor)
])
}
// MARK: Header
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
if kind == UICollectionView.elementKindSectionHeader {
let sectionHeader = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "header", for: indexPath) as! Header
return sectionHeader
}
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
let width: CGFloat = collectionView.frame.width
let height: CGFloat = 33 + 20
return CGSize(width: width, height: height)
}
// MARK: - UICollectionViewDataSource
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 10
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! SessionCell
return cell
}
// MARK: - UICollectionViewDelegateFlowLayout
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let width = collectionView.bounds.width
let height = 150
return CGSize(width: collectionView.bounds.width, height: height)
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
print(indexPath.row)
}
}
struct SessionsCollectionViewWrapper: UIViewRepresentable {
var sessionViewNavigation: SessionViewNavigation
func makeUIView(context: Context) -> SessionsCollectionView {
let sessionsCollectionView = SessionsCollectionView()
return sessionsCollectionView
}
func updateUIView(_ uiView: SessionsCollectionView, context: Context) {
// Update any properties or handle updates if needed
}
}