I have a TableviewController which has multiple customs cells. One of them has a CollectionView (inside the tableView cell). In the CollectionView Cell I have as Image View where I need to display a map. Everything works but when I navigate to the TableviewController for the first time and scroll down I get a glitch/lag/frame drop at a certain spot. this only happens once and if you go back to the previous view then again to the TableView Controller the lag doesn't seem to be present.
If I don't set the map image then the lag goes away so this is definitely causing that issue.
// TableView cellForRowAt
case .branchesCell:
let cell = tableView.dequeueReusableCell(withIdentifier: "branchesCell", for: indexPath) as! BranchesCell
cell.branches = restaurant?.branches
cell.restaurantName = restaurant?.metadata.name ?? ""
return cell
// Tableview Cell Class - BranchesCell
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! NestledBranchCell
cell.layer.masksToBounds = false
cell.backgroundColor = .clear
if let branches = branches {
cell.branch = branches[indexPath.row]
cell.restaurantName = restaurantName
}
return cell
}
// Collectionview Cell Class - NestledBranchCell
override func awakeFromNib() {
super.awakeFromNib()
contentView.layer.applySketchShadow(color: .black, alpha: 0.14, x: 0, y: 7, blur: 14, spread: 0)
containerView.clipsToBounds = true
containerView.layer.cornerRadius = 15
tradingStatusLbl.layer.cornerRadius = 10
tradingStatusLbl.layer.masksToBounds = true
directionsBtn.layer.cornerRadius = 10
callBtn.layer.cornerRadius = 10
}
override func draw(_ rect: CGRect) {
super.draw(rect)
setupCell() // Setting a few labels
Task {
await setupMap()
}
}
func setupMap() async {
if let branch = branch {
let mapSnapshotOptions = MKMapSnapshotter.Options()
let location = branch.coordinates.coordinate
let region = MKCoordinateRegion(center: location, latitudinalMeters: 300, longitudinalMeters: 300)
mapSnapshotOptions.region = region
mapSnapshotOptions.scale = UIScreen.main.scale
let size = CGSize(width: 314, height: 195)
mapSnapshotOptions.size = size
mapSnapshotOptions.showsBuildings = true
mapSnapshotOptions.pointOfInterestFilter = .none
let snapShotter = MKMapSnapshotter(options: mapSnapshotOptions)
snapShotter.start { snapshot, error in
let image = snapshot?.image
self.imageView.image = image
}
}
}
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I have a basic List made in SwiftUI. When I scroll with the Digital Crown I get the "light haptics" however when I get to the top or bottom of the list I don't get the more pronounced dent.
Update - If I use a plain list style then I get the haptics as expected. However it should work with the elliptical style as this is used in the system.
The console outputs the following
2022-05-19 23:32:53.782614+0200 WatchApp WatchKit Extension[326:41020] [default] Error: Error Domain=NSOSStatusErrorDomain Code=-536870187 "(null)"
2022-05-19 23:32:53.783181+0200 WatchApp WatchKit Extension[326:41020] [detents] could not play detent NO, 2, Error Domain=NSOSStatusErrorDomain Code=-536870187 "(null)", (
{
Gain = "0.01799999922513962";
OutputType = 0;
SlotIndex = 4;
},
{
Gain = "0.4900000095367432";
OutputType = 1;
SlotIndex = 5;
}
)
Here is my code
struct ContentView: View {
var body: some View {
List {
ForEach(0..<100) { i in
NavigationLink(destination: FeedView()) {
Text("Hello")
}
}
}.navigationTitle("Title")
}
}
I'm trying to recreate the watchOS App Store layout however there are a few parts I am not how to recreate.
When scrolling an Elliptical Style List the cells will "snap" up if you are scrolling slowly. This effect works well with regular size cells with just a line of text but makes the List scrolling seem a glitchy when the cells are taller.
In the App Store app this "snap" effect is not there. When scrolling there is still a visible "Elliptical Scroll Style" but this effect is missing for the "See All" cells which scroll as if it were a "Plain Style List". How would you create this effect?
Also when using a Plain Style List and you scroll to the very top or bottom you get a "heavy" haptic feedback which is absent on Elliptical Style Lists. The App Store app still has this "heavy" haptic feedback when you get to the top or bottom yet it uses an Elliptical List style (or at least something in between as explained above.)
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/
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 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)")
}
}
In a section of my app I would like to recommend restaurants to users based on certain parameters. Some parameters have a higher weighting than others. In this WWDC Video a very similar app is made.
Here if a user likes a dish a value of 1.0 is assigned to those specific keywords (that apple to the dish) with a value of -1.0 to all other keywords that don't apply to that dish.
For my app if the user has ordered I then apply a value of 1.0 (to the keywords that apply) but if a user has just expressed interest (but not ordered) then can I apply a value of 0.5 (and -0.5) instead, would the model adapt to this?
I have button inside a CollectionViewCell and when tapped I want to run an animation. The animation doesn't run and I'm not sure why.
Inside the Cell class
@IBAction func hoursExpandBtnTapped(_ sender: Any) {
UIView.animate(withDuration: 3, delay: 0, options: .curveLinear) { [self] in
addressLbl.frame = CGRect(x: addressLbl.frame.minX, y: addressLbl.frame.minY, width: 20, height: addressLbl.frame.height)
} completion: { _ in
}
}
One part of my app uses CreateML but I still need to test the UI on other screen sizes with the simulator. I tried using this condition but still get the same error.
#if os(iOS)
import CreateML // CreateML is not available when building for iOS Simulator. Consider using `#if os(iOS)` to conditionally import this framework when building for iOS.
#endif
How do you set the size of an area light in sceneKit?
let areaLightNode = SCNNode()
areaLightNode.light = SCNLight()
areaLightNode.light!.type = .area
areaLightNode.position = SCNVector3(x: 0, y: 5, z: 0)
areaLightNode.light?.intensity = 1000
Nothing appears when using the above
I have a collectionView inside my UIKit view controller using UIViewControllerRepresentable (App is SwiftUI). How can I segue to another view when a cell is tapped. Usually I’d just segue from didSelectCellAt but how can I create a SwiftUI NavigationLink from there? (I will be switching to another Viewcontroller)
I removed a pod from my project and when I went to commit I got a whole list of the deleted files marked with exclamation marks saying they're "missing". I've cleaned the build folder, deleted derived data etc but these still keep coming up.
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?