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

Compare enums in Swift
protocol extension implementing KVO complaint property
Trouble using cblas_dgemm for matrix multiplication in Swift
Inline if statement mutating inout parameter in a void return closure, weird error (Error: type 'Int1' does not conform to protocol 'BooleanType')
How do I pass variables to Cloud Code from Swift?
How to read swift headers
Swift if sentences issue
Passing function with multiple arguments as a closure in Swift
searchBarController doesn't follow the text when searching, cancel doesn't work like it should
Can I have SKSpriteNodes show up on a different scene during a transition
Can not access an SKSpriteNode from within a function
How to use committedValuesForKeys to save and reconstitute NSManagedObjects?
NSTask putting extra single quote in command
How to get focused view frame size in tvOS?
Swift init with function to make clear separation
How to access a variable value outside of Parse's getObjectInBackgroundWithId block

Categories

HOME
arrays
ubuntu-16.04
agile
chaiscript
couchdb-2.0
data-science-experience
xcode8.3
flann
local
webmethods
rapidjson
lenskit
yeoman-generator
zoomcharts
factor-analysis
chocolatey
eclipselink
multicore
jive
jquery-scrollify
searchbar
yosys
python-textprocessing
osmdroid
ui5
websauna
strophe
construct-2
skygear
hawtio
geo
modulo
broadleaf-commerce
stdclass
ttcn
filepath
data-integration
walmart-electrode
number-theory
amazon-machine-learning
gauss
spell-checking
text-classification
mbaas
tcserver
nuget-server
lotus
keycode
tomee
rmongodb
pax-web
gherkin
database-backups
brython
clob
gradle-release-plugin
sun-codemodel
handlebars.java
geodjango
windows-vista
findcontrol
gulp-livereload
google-hadoop
searchkick
jython-2.7
sqoop2
cpan
pgagent
node-inspector
collabnet
ghostdoc
mov
code-testing
pic24
map-force
jstack
initialization-vector
resource-files
hamsterdb
magicalrecord-2.2
bignum
cilk-plus
installshield-2011
fraud-prevention
magickwand
symfony-2.0
isolatedstorage
supersized
nintendo
goliath
drawtext
microsoft.ink
data-entry





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