ios


UIPickerView not displaying data in the UIViewController


Could you please look over my code for a UIPickerView? The pickerView shows nothing in the UIViewController but when I print the picker data on the console, it shows the correct data.
Outside of viewDidLoad():
var pickerDataSource = Array<String>()
Inside my viewDidLoad():
pickeroftheView.delegate = self
pickeroftheView.dataSource = self
if numberOfMultiPlayers == 2 {
pickerDataSource = ["\(multi1Name)", "\(multi2Name)"]
}else if numberOfMultiPlayers == 3{
pickerDataSource = ["\(multi1Name)", "\(multi2Name)", "\(multi3Name)"]
}else if numberOfMultiPlayers == 4{
pickerDataSource = ["\(multi1Name)", "\(multi2Name)", "\(multi3Name)", "\(multi4Name)"]
}else if numberOfMultiPlayers == 5{
pickerDataSource = ["\(multi1Name)", "\(multi2Name)", "\(multi3Name)", "\(multi4Name)", "\(multi5Name)"]
}else if numberOfMultiPlayers == 6{
pickerDataSource = ["\(multi1Name)", "\(multi2Name)", "\(multi3Name)", "\(multi4Name)", "\(multi5Name)", "\(multi6Name)"]
}
print("Data Source: \(pickerDataSource)")
}
Code:
func numberOfComponents(in pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return pickerDataSource.count
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return pickerDataSource[row]
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
if row == 0 {
giverNumber = 1
} else if row == 1 {
giverNumber = 2
} else if row == 2 {
giverNumber = 3
} else if row == 3 {
giverNumber = 4
} else if row == 4 {
giverNumber = 5
} else if row == 5 {
giverNumber = 6
}
}
Thanks in advance!

Related Links

How to use delegates properly in Swift?
swift stop 360 degree animation
Core Data App group synchronization (w/ extension)
iOS Bugsnag exception - EXC_BAD_ACCESS _dispatch_dispose Attempted to dereference garbage pointer
why my array is null in second time, when I assigned it's first object to dictionay in objective C, ios
Why text get line break when scroll
Writing text on pdf ios
How to achieve this layout on buttons and text fields in XCode using swift? [closed]
how to trim a video in swift for a particular time
Returning Whether Dictionary or Array from function?
Scrollview is leaving top space
Google Sign-In crashes on iOS 9.2 attempting to call canOpenURL [duplicate]
cloudkit sync with local database
AutoLayout: when to use bottomLayoutGuide vs. “V:[continueButton(50)]|”
swift invalidate timer in function
How to parse xml in ios?

Categories

HOME
ios
groovy
google-apis-explorer
copy
ssl-certificate
android-sqlite
azure-web-sites
isis
fonts
chronicle
payment-processing
http2
activerecord
stm
overloading
frequency
cytoscape.js
scope
axure
lighttpd
lag
partitioning
web-audio
round-robin
garmin
ssrs-2008
zap
google-finance
atg
aikau
background-subtraction
hawq
regex-group
android-button
arduino-esp8266
stl
matterjs
stomp
azure-api-apps
spring-websocket
advanced-installer
edit-distance
sieve-of-eratosthenes
outlook-vba
spring-data-cassandra
dwm
confirm
apartment-gem
runge-kutta
ipod-touch
rft
nomenclature
worldpay
google-slides
gradle-tooling-api
quicksand
backwards-compatibility
ewsjavaapi
multistore
domdocument
replaygain
html-lists
catalina
cabal-install
bootstrap-slider
git-config
texture2d
benerator
blpapi
vimeo-ios
pddl
pakyow
cucumber-java
administrator
multiple-files
tag-helpers
actioncable
ospf
delphi-10-seattle
gevent-socketio
crowdflower
smarty2
antiforgerytoken
vraptor
sqlhelper
email-spam
textselection
data-quality
xml.modify
keymapping
preon
data-dictionary
showcaseview
modx-evolution
xcache
qdebug
mms-gateway
jquery-data
geometry-surface
lungojs
rpn
media-manager
hpple
ed
azure-role-environment
duplicate-data
ramaze
regexbuddy
excel-web-query
net-ssh
clipboard-pictures
plumtree

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