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

Refresh control not sliding screen back up after refreshing in Swift
how to continue animation and uitimer in background
Swift 3 Getting Optionals After Initializing Class [duplicate]
Static and lazy variables: similar behaviours?
RxSwift: Observe viewDidLoad from view model without Subjects
How can I export Image as 3DL or Cube File?
core data and relationship predicate
UIScrollView contentSize doesn't work
Unusual high CPU usage in UITableView
How can you test that an index is out of range in Swift?
Run timer in a specific time (swift)
Swift 3 pdf file download not working
Swift allow user to choose player Sprite Node
How to correctly unset an array from UserDefaults in Swift
NSCollectionView `validateDrop` delegate not getting called
How to return early from an init in swift 3

Categories

HOME
ajax
sidekiq
winapi
firebase-app-indexing
visual-studio-2013
vs-team-services
smartphone
aem
thunderbird-addon
quill
tumblr
sequelize.js
simpy
vsftpd
ng-admin
getorgchart
cartodb
data-analysis
maxima
sign
rebol2
factor-analysis
koa
richfaces
explode
memsql
shopping-cart
lync-2013
version-numbering
mayavi
fileinfo
mangodb
forum
superscript
xor
protobuf-net
fabric-digits
nsurlconnection
nunit-3.0
pmwiki
active-model-serializers
common.logging
floating-accuracy
code-composer
mediawiki-extensions
knockout-3.0
nsjsonserialization
istorage
tiddlywiki
spring-data-hadoop
slidesjs
mcrypt
fontconfig
castle-dynamicproxy
addin-express
pdfkit
gulp-typescript
uistackview
dts
radians
foxit
unsatisfiedlinkerror
soda
clob
achievements
proxygen
aerogear
asymptote
jta
intellitest
code-readability
rad
js-cookie
wif
urn
prezto
on-duplicate-key
graphical-logo
twitter-rest-api
apache-mina
robocode
cpan
libsndfile
jquery-autocomplete
em
method-overriding
ember-addon
dache
level
pic24
ifft
config-files
roxygen
real-time-updates
multiple-login
ruboto
carddav
ienumerator
mstsc
resgen
vt100
git-filter-branch
couchdb-lucene
shim
getstring
parameterization
driving-directions
flexicious
goliath
windows-live-id
sendfile
recordset
task-management
nt4
internals
dirty-data
configurable
usergroups





Mobile Apps Dev
Database Users
javascript
java
csharp
php
android


MS Developer
developer works
python
ios
c
html
jquery


RDBMS discuss