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 wait for finish dataTaskWithRequest?
Sequencing sounds with a delay in Swift
iOS 9 searchBar disappears from table header view when UISearchController is active
MFMessageComposeViewController not returning to application after send message ios9
This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes.
Writing a flood-fill method in Swift
Facebook Graph API query for latest album from page
Options for sending data to server/retrying requests in background
xcode, ios, Help Image Freezes, Not Moving
Hidden property cannot be changed within an animation block
MPmoviePlayer going black after updating to IOS 9 ( swift )
Run custom script after iOS app is signed in XCode
Video frames fill only 1/4 of the view - GL
How can I change the image in the detail view to access the master view
Can I use swift 1.2 with iOS 9? [closed]
Why same nsmutablearray gives me valid value and a null on different functions used

Categories

HOME
common-lisp
android-sqlite
applet
amazon-kinesis
streaming
logback
android-sms
ceph
tcplistener
copy-paste
overloading
sqlconnection
doorkeeper
marketplace
zend-expressive
tapi
graph-tool
calabash-android
rebus
python-2.5
amplitude
durandal-2.0
windows-applications
haml
similarity
netlify
spark-graphx
google-distancematrix-api
nice-language
easendmail
mediator
epicorerp
memorystream
kprobe
ruamel.yaml
gecko
breakpoint-sass
html-select
machine-language
hamcrest
presto
confirm
message-hub
qmake
backwards-compatibility
openwebanalytics
html-form
uservoice
mrtg
abbyy
flying-saucer
lcov
gpt
jcuda
omniauth
findall
jasny-bootstrap
file-import
ng-annotate
cufft
formatter
duration
app-engine-ndb
mutation
yapdatabase
training-data
administrator
flexigrid
java-gstreamer
radix-sort
text-alignment
many-to-one
android-gpuimageview
heroku-toolbelt
kindlegen
tabbar
mailx
gevent-socketio
wintersmith
horizontalscrollview
razor-2
citymaps
team-explorer-everywhere
disk-io
nsusernotificationcenter
mosek
asp.net-authentication
src
cloud-hosting
google-provisioning-api
51degrees
proxy-classes
f2c
demoscene
ssao
blackberry-os-v5
openfeint

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