swift


Button on Annotation is not appearing


I have a problem with my app. In fact, when I am running my code in a separate app it is working. xCode is not showing me any errors and everything works fine but I can't see a detail button in my Annotations on MapKit. Is there a problem deeper in xCode?
That is my code:
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
let identifier = "Education"
if annotation is Education {
var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: identifier)
if annotationView == nil {
annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: identifier)
annotationView!.canShowCallout = true
let btn = UIButton(type: .detailDisclosure)
annotationView!.rightCalloutAccessoryView = btn
} else {
annotationView!.annotation = annotation
}
return annotationView
}
return nil
}
It looks like this on my app - no detail button on the right side of annotation.
you have to set the delegate for your mapView. I usually do it in the viewDidLoad of the ViewController the mapView is in.
mapView.delgate = self
is the code you need to add.

Related Links

Passing a function to a class in Swift
swift - UICollectionView issue “fatal error: unexpectedly found nil while unwrapping an Optional value”
Search Bar - filtering numeric value in swift
error: missing argument for parameter #1 in call (swift)
NSURLSession concurrent requests with Alamofire
Why need get/set when using Computed Properties in Swift, while we can code without them actually?
Trying to conform to StringLiteralConvertible
LLDB swift print object
Changing position.x causes skspritenode to not display
Wait until an asynchronous api call is completed - Swift/IOS
Read lines from big text file in Swift until new line is empty: the Swift way
how do i enable autofill password for a wkwebview
Multidimensional dictionaries possible in Swift?
Access instance constant in lazy constructor
Typecase regular Swift function to Curry Function
What's the most efficient way to determine if a Swift string is shorter than a certain length

Categories

HOME
xbox-live
crystal-reports
sass
project-management
nuxeo
memory-leaks
hana
matplotlib
orientation
flyway
hyperledger-fabric
adsense
jrebel
java-home
data-science-experience
requirejs
shipping
constructor
flexbox
rfid
ida
netezza
zoho
clover
android-fragmentactivity
cython
esql
dspic
azure-servicebus-queues
non-deterministic
data-cleansing
geopandas
widevine
image-quality
system.data.sqlite
blackboard
twitter-bootstrap-2
strophe
smart-mobile-studio
backup-strategies
m2e
spreedly
reactivemongo
service-locator
google-guava-cache
shibboleth
axis-labels
deepstream.io
alchemy.js
archer
web-deployment-project
multi-agent
cgcontext
pagefile
paas
search-box
keycode
verbose
nsfetchedresultscontrolle
libreadline
windows-azure-pack
excon
multifile-uploader
clob
search-regex
asp.net-mvc-partialview
supportmapfragment
self-hosting
vips
abas
base32
wif
apache-mina
mdm-zinc
em
jstat
sid
cppdepend
lumx
bounds
android-json-rpc
sanitization
facebook-chat
google-closure-library
appfog
awesomeprint
icsharpcode
sequelpro
returnurl
blockingqueue
fotoware
objective-c-protocol
jquery-selectbox
collect
port-scanning
audiostreamer
j-interop
osx-leopard
quick-search
google-instant

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App