Carousel Selection
Maps UIKit SwiftUI
With out carousel UI rendered out now, we can move onto display map item information in each cell. To do this, we'll modify the generic type for our controller. Next we can pass in the map items from our local search response directly into the carousel. The last step to wrap up this entire feature is to make sure on selection of the carousel, we can select the correct annotation on the map.

Comments (8)
Eugeneberezin
3 years ago
Hey Brian. First of, it's a very cool course! Love it. Hey I have a problem. The collection view for the addresses is not rendering. I don't see any cards. I triple check the code, everything is correct. I also downloaded your project. Funny thing it's not working for the project that I downloaded either. Xcode / Swift 5.1 update problem? I am using Version 11.2.1. I do remember people were talking about that collection view is not quite working here recently.
Brian Voong
3 years ago
Eugeneberezin
3 years ago
Yup. I'll add a method to hide the keyboard if I tap away. I was looking at the preview. and it still acting weird not rendering the collection view. Thanks, man.
Brian Voong
3 years ago
weare99
3 years ago
I have make the project with the new UICollectionViewDiffableDataSource feature. If anyone is interested how the codes works you can clone or download the project on my GitHub Page https://github.com/alexroemerdeveloper/LocalSearch.git
pdefilippi
3 years ago
Hey Brian, I can't get any search results in the simulator to show up using only - _ = NotificationCenter.default .publisher(for: UITextField.textDidChangeNotification, object: searchTextField) .debounce(for: .milliseconds(500), scheduler: RunLoop.main) .sink { (_) in self.performLocalSearch() } I have to use the old school approach in order to get results. I can't figure out why because the code looks correct. It is not working on your project that I downloaded from this video also. I am running the iPhone 11 pro max simulator 13.3 and Xcode 11.3. Any help would be awesome.
Brian Voong
3 years ago
pdefilippi
3 years ago
ahhh, no worries. Thanks for the quick response. Ill check out episode 16.
NSD_bigjas00
3 years ago
To dismiss the keyboard I added: ... .sink{ (_) in self.performLocalSearch() self.searchTextField.resignFirstResponder() }
frankusu
3 years ago
amaze
frankusu
3 years ago
Hey Brian amazing stuff! Do you ever go over how to scroll the collectionView when a pin is tapped? Right now we have select annotation when collectionView is tapped. Thanks!
frankusu
3 years ago
Hey, Brian, I built off your idea, please let me know if there is a better way! :) extension MainController : MKMapViewDelegate { func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) { for (index, item) in locationsController.items.enumerated() { if item.name == view.annotation!.title { locationsController.collectionView.scrollToItem(at: [0,index], at: .centeredHorizontally, animated: true) } } } }
Brian Voong
3 years ago
frankusu
3 years ago
Just realized secret sauce in episode 10
shivaskanthan
3 years ago
Wondering why you didn't go for a delegate and protocol method at the end?
astericky
3 years ago
Is anyone else running into: libMobileGestalt MobileGestalt.c:1647: Could not retrieve region info Failed local search: Error Domain=MKErrorDomain Code=4 "(null)" UserInfo={MKErrorGEOError=-8} for the last few videos I have bene running into this issue and I am not sure how to fix it.
Brian Voong
3 years ago
astericky
3 years ago
I'm in Oakland, CA.
Brian Voong
3 years ago
astericky
3 years ago
I get the same issue with the code from this lecture.
Brian Voong
3 years ago
astericky
3 years ago
Simulator on my MBP
Brian Voong
3 years ago
astericky
3 years ago
I ran into the same issue on my personal device.
astericky
3 years ago
If figured out the issue. It's the notification center part that's not working whoohoo!!! So I'll look in chapter 16 for the update.
Greg Reda
2 years ago
How can you dismiss and reload the collection view with a swipe?
HELP & SUPPORT