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 get latitude and longitude while there is no internet connection
iOS: UITextView with custom NSTextStorage crashes
Swift CoreData: Failed to call designated initializer on NSManagedObject
Access Notification Center / Today view
In-App Purchase basic app with additional premium features app in iOS
Playback Video in iOS inside a custom view
Does iOS development have a text layout representation (XML or other)?
Set SCNNodes to have constant y-axis value?
PrepareForSegue method crashes app iOS
Label shows 2 text values on refresh
Xcode “arpa/telnet.h” file not found
Scroll View unavailable on all Iphones, Swift
Usage of objective-c core data model in an swift class
Make a UIActivityIndicator with background, position centre of the main View in Swift
Swift UINavigationBar background color is different from main one
How to pass a Parse File to a new View Controller

Categories

HOME
html5-canvas
coffeescript
datetime
geolocation
asana
swashbuckle
turing
robot
visual-studio-2012
gluon
wikipedia-api
binary-search
eps
zend-expressive
editor
numericupdown
calabash-android
prerender
lazy-loading
missingmethodexception
microphone
nice-language
robotium
precision
listbox
structure
flexjs
flatbuffers
vue-router
spring-websocket
rhel7
mask
microsoft-translator
ibm-wcm
subscription
angular2-seed
linear
nexus-5
docker-swarm-mode
spring-form
okular
fasta
itertools
glumpy
iseries-navigator
vistadb
proc
turnjs
ng-annotate
webdeploy-3.5
securesocial
python-3.1
pypyodbc
aplpy
yapdatabase
egl
relaxng
python-dragonfly
ospf
sejda
symbian
ubiquity
gulp-rename
mkpolyline
vraptor
javaw
imake
before-save
datacontractserializer
master-theorem
twill
hobbitmon
sysadmin
floating-point-conversion
emacs-jedi
rte
zephir
pubdate
hla
tempo
jsr223
maven-bundle-plugin
ruby-1.9.2
bapi
gemstone
blackberry-jde
nscollectionviewitem
jquery-1.3.2
noaa
indextank
arraycopy

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