Post

Replies

Boosts

Views

Activity

UITableView indexPath changing while scrolling
In my Table View I have the label text set to a different colour if the name is in the Flagged Array (flaggedNames). The correct cell labels turn red but as I scroll the text of other labels are also red. This changes as I scroll.     override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {         let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)         let name = names[indexPath.row]         cell.textLabel?.text = name         if flaggedNames.contains(meterNumber) {             cell.textLabel?.textColor = .systemRed         }         return cell     }
3
0
913
Sep ’21
Error -> init(coder:) has not been implemented
I'm trying to access another class in my CollectionView Controller but when I try and initialise the class I get the error Here is the class @MainActor class AlbumsViewModel {     private let albumService: AlbumService     private let favouritesService: FavouritesService     private let recommendationService: RecommendationService     @Published var favourites = [Bool]()     @Published var recommendedAlbums = [Album]()     @Published var allAlbums = [Album]() {         didSet {             updateFavourites()         }     }     init(albumService: AlbumService, favouritesService: FavouritesService, recommendationService: RecommendationService) {         self.albumService = albumService         self.favouritesService = favouritesService         self.recommendationService = recommendationService     } ...(functions here) Collectionview Controller Class class CVC: UICollectionViewController, UICollectionViewDelegateFlowLayout {     var viewModel: AlbumsViewModel     init?(viewModel: AlbumsViewModel, coder: NSCoder) {         self.viewModel = viewModel         super.init(coder: coder)     }     required init?(coder: NSCoder) {         fatalError("init(coder:) has not been implemented")     }     override func viewDidLoad() {         super.viewDidLoad()         collectionView.delaysContentTouches = false         Task {             print(viewModel.allAlbums)         }     } // End viewDidLoad ... Trying to recreate this https://martinmitrevski.com/2021/07/11/ml-recommendation-app-with-create-ml-on-ios-15/
7
0
2.6k
Jan ’22
Laggy TableView scrolling
In my tableview I have a few custom cells. When I scroll in the tableview it lags in the same spot but only for the first time the app is open. if I go back to the root view then open the tableview again it doesn't seem to lag. I've traced the lag to one cell. In that cell I have an embedded collection view and each of those cells has image view with is showing a MKMapSnapshot and also a few labels etc. If run with 0 collectionView cells (numberOfCellsInSection) the tableview scrolls smoothly but lags when I have 1 or more CollectionViewCell cells. I initially loaded the image in the collectionView cell class in layoutSubviews which worked but I then learned that this is called numerous times so code like that shouldn't be there. if I put it in awakeFromNib the Branch struct doesn't seem to have been passed to the cell as yet (from cellForRowAt) so it doesn't work there. I then moved setting the image in cellForItemAt but I'm still not sure if it is correct there. // Table View cellForRowAt         case .branchesCell:             let cell = tableView.dequeueReusableCell(withIdentifier: "branchesCell", for: indexPath) as! BranchesCell             cell.branches = restaurant?.branches // This is the info the embedded collectionView cell should display. Text for labels and coordinates for the MKMapSnapshot.             return cell // TableView Cell Class class BranchesCell: UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource {     @IBOutlet var collectionView: UICollectionView!     var branches: [Branch]?     var restaurantName = String()     override func awakeFromNib() {         super.awakeFromNib()         collectionView.delegate = self         collectionView.dataSource = self         collectionView.backgroundColor = .clear         collectionView.delaysContentTouches = false     }     // MARK: UICollectionView     func numberOfSections(in collectionView: UICollectionView) -> Int { return 1 }     func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {         if let branches = branches {             return branches.count         } else { return 0 }     }          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         let imageView = cell.viewWithTag(1) as! UIImageView         if let branches = branches {             cell.branch = branches[indexPath.row]             cell.restaurantName = restaurantName // Tried to run this in a different thread to see if it would make a difference.             DispatchQueue.main.async() { [self] in                 let size = CGSize(width: 314, height: 195) // Set the image here                 getMapImage(branch: branches[indexPath.row], size: size) { mapImage in                     imageView.image = mapImage                 }             }         }         return cell     }     func getMapImage(branch: Branch, size: CGSize, completion: @escaping (UIImage?) -> ()) {         var mapImage = UIImage()         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         mapSnapshotOptions.size = size         mapSnapshotOptions.showsBuildings = true         mapSnapshotOptions.pointOfInterestFilter = .none         let snapShotter = MKMapSnapshotter(options: mapSnapshotOptions)         snapShotter.start { snapshot, error in             let image = snapshot?.image             mapImage = image!             completion(mapImage)         }     } }
2
0
2.8k
Jan ’22
How to get multiple camera streams?
I have an ARSCNView with nodes in AR. The UI guides you in scaling an object and the images captured are used to create a 3D model. When I try take a picture using arView.snapshot() it basically takes a screenshot a the resolution is the screen resolution and the nodes are visible. I also noticed that the AR View displays a lower quality output than the camera app. If I try get a separate camera output with AVFoundation then the arView doesn't get an output and vive versa, it only allows one view to access the camera. Is it possible to get a full resolution image without the nodes visible from the AR View (if I hide them, capture the image and display them again they do flicker) or is it possible to have 2 camera streams one to the arView and the other used to solely capture images (this one does not need to visible on screen)
1
0
992
Jul ’23
No Start/End Haptics when scrolling through List on watchOS
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")         } }
0
1
1.4k
May ’22
UITableView indexPath changing while scrolling
In my Table View I have the label text set to a different colour if the name is in the Flagged Array (flaggedNames). The correct cell labels turn red but as I scroll the text of other labels are also red. This changes as I scroll.     override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {         let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)         let name = names[indexPath.row]         cell.textLabel?.text = name         if flaggedNames.contains(meterNumber) {             cell.textLabel?.textColor = .systemRed         }         return cell     }
Replies
3
Boosts
0
Views
913
Activity
Sep ’21
Error -> init(coder:) has not been implemented
I'm trying to access another class in my CollectionView Controller but when I try and initialise the class I get the error Here is the class @MainActor class AlbumsViewModel {     private let albumService: AlbumService     private let favouritesService: FavouritesService     private let recommendationService: RecommendationService     @Published var favourites = [Bool]()     @Published var recommendedAlbums = [Album]()     @Published var allAlbums = [Album]() {         didSet {             updateFavourites()         }     }     init(albumService: AlbumService, favouritesService: FavouritesService, recommendationService: RecommendationService) {         self.albumService = albumService         self.favouritesService = favouritesService         self.recommendationService = recommendationService     } ...(functions here) Collectionview Controller Class class CVC: UICollectionViewController, UICollectionViewDelegateFlowLayout {     var viewModel: AlbumsViewModel     init?(viewModel: AlbumsViewModel, coder: NSCoder) {         self.viewModel = viewModel         super.init(coder: coder)     }     required init?(coder: NSCoder) {         fatalError("init(coder:) has not been implemented")     }     override func viewDidLoad() {         super.viewDidLoad()         collectionView.delaysContentTouches = false         Task {             print(viewModel.allAlbums)         }     } // End viewDidLoad ... Trying to recreate this https://martinmitrevski.com/2021/07/11/ml-recommendation-app-with-create-ml-on-ios-15/
Replies
7
Boosts
0
Views
2.6k
Activity
Jan ’22
Laggy TableView scrolling
In my tableview I have a few custom cells. When I scroll in the tableview it lags in the same spot but only for the first time the app is open. if I go back to the root view then open the tableview again it doesn't seem to lag. I've traced the lag to one cell. In that cell I have an embedded collection view and each of those cells has image view with is showing a MKMapSnapshot and also a few labels etc. If run with 0 collectionView cells (numberOfCellsInSection) the tableview scrolls smoothly but lags when I have 1 or more CollectionViewCell cells. I initially loaded the image in the collectionView cell class in layoutSubviews which worked but I then learned that this is called numerous times so code like that shouldn't be there. if I put it in awakeFromNib the Branch struct doesn't seem to have been passed to the cell as yet (from cellForRowAt) so it doesn't work there. I then moved setting the image in cellForItemAt but I'm still not sure if it is correct there. // Table View cellForRowAt         case .branchesCell:             let cell = tableView.dequeueReusableCell(withIdentifier: "branchesCell", for: indexPath) as! BranchesCell             cell.branches = restaurant?.branches // This is the info the embedded collectionView cell should display. Text for labels and coordinates for the MKMapSnapshot.             return cell // TableView Cell Class class BranchesCell: UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource {     @IBOutlet var collectionView: UICollectionView!     var branches: [Branch]?     var restaurantName = String()     override func awakeFromNib() {         super.awakeFromNib()         collectionView.delegate = self         collectionView.dataSource = self         collectionView.backgroundColor = .clear         collectionView.delaysContentTouches = false     }     // MARK: UICollectionView     func numberOfSections(in collectionView: UICollectionView) -> Int { return 1 }     func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {         if let branches = branches {             return branches.count         } else { return 0 }     }          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         let imageView = cell.viewWithTag(1) as! UIImageView         if let branches = branches {             cell.branch = branches[indexPath.row]             cell.restaurantName = restaurantName // Tried to run this in a different thread to see if it would make a difference.             DispatchQueue.main.async() { [self] in                 let size = CGSize(width: 314, height: 195) // Set the image here                 getMapImage(branch: branches[indexPath.row], size: size) { mapImage in                     imageView.image = mapImage                 }             }         }         return cell     }     func getMapImage(branch: Branch, size: CGSize, completion: @escaping (UIImage?) -> ()) {         var mapImage = UIImage()         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         mapSnapshotOptions.size = size         mapSnapshotOptions.showsBuildings = true         mapSnapshotOptions.pointOfInterestFilter = .none         let snapShotter = MKMapSnapshotter(options: mapSnapshotOptions)         snapShotter.start { snapshot, error in             let image = snapshot?.image             mapImage = image!             completion(mapImage)         }     } }
Replies
2
Boosts
0
Views
2.8k
Activity
Jan ’22
Xcode still tracking deleted files
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.
Replies
1
Boosts
0
Views
1.3k
Activity
Nov ’22
Does the RX 580 support Object Capture?
I'm looking to get a GPU to use for Object capture. The requirements are an AMD GPU with 4GB of VRAM and ray tracing support, the rx 580 seems to be able to do ray tracing from what I've found online but looks like someone had an issue with a 580X here https://developer.apple.com/forums/thread/689891
Replies
3
Boosts
0
Views
1.7k
Activity
Jul ’23
How to get multiple camera streams?
I have an ARSCNView with nodes in AR. The UI guides you in scaling an object and the images captured are used to create a 3D model. When I try take a picture using arView.snapshot() it basically takes a screenshot a the resolution is the screen resolution and the nodes are visible. I also noticed that the AR View displays a lower quality output than the camera app. If I try get a separate camera output with AVFoundation then the arView doesn't get an output and vive versa, it only allows one view to access the camera. Is it possible to get a full resolution image without the nodes visible from the AR View (if I hide them, capture the image and display them again they do flicker) or is it possible to have 2 camera streams one to the arView and the other used to solely capture images (this one does not need to visible on screen)
Replies
1
Boosts
0
Views
992
Activity
Jul ’23
No Start/End Haptics when scrolling through List on watchOS
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")         } }
Replies
0
Boosts
1
Views
1.4k
Activity
May ’22