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

SWIFT: Making the heightForRowAtIndexPath of tableViewCell to be dynamic [duplicate]
Value of optional type 'String' not unwrapped; did you mean to use '! or '?' [duplicate]
Button click event inside a map marker info window
How do I rotate sprites on a perimeter of a circle towards the center?
Swift: Use guard with or statement
Disable controller in tvOS
Swift nstimer accessing function other class
Can't create a range in Swift 3
Swift: Geofire Instanciation error after Firebase 3 upgrade
Capture lists: reference to class instance or initialized variable?
SQlite Swift unexpected result group
“Type 'task.Type' has no subscript members” swift [duplicate]
UICollectionView behavior is incorrect as Subview
Creating Rounded UILabel in Swift
Swift: Expected ',' separator [closed]
Accessing var from another class or scene in SpriteKit

Categories

HOME
drupal-7
warnings
label
memory-leaks
urlencode
spring-cloud-contract
data-science-experience
i2c
actionscript-2
subquery
gimp
dropbox
viber
future
eclipse-luna
uisplitviewcontroller
medium-editor
factor-analysis
atlassian-plugin-sdk
jsonserializer
boolean-expression
jni
backpropagation
remove-method
katharsis
geopandas
codelite
upnp
edge-detection
i3
ioc-container
apache-cloudstack
entity-system
backup-strategies
npm-shrinkwrap
von-neumann
openpgp
google-guava-cache
ntfs-mft
rule
lftp
lumen-5.3
taskmanager
ti-basic
ogre3d
tofixed
info
iron.io
pspice
atlassian-crowd
c64
rmongodb
spark-cassandra-connector
boost-hana
image-editing
search-regex
multinomial
void
lemoon
document-oriented-db
insert-into
matcaffe
python-winshell
pyopengl
criteria-api
lines-of-code
es2015
client-side-validation
jquery-autocomplete
ogr2ogr
iostream
level
lov
arangodb-php
jquery-tabs
opendata
logentries
cilk-plus
javascriptmvc
process-monitor
attachevent
static-variables
continuous-testing
jpf
supersized
objectbrowser
ruby-debug
unreachable-code
delegatecommand
graniteds
castle-validators
standardized

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