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

Xamarin MainStoryBoard opening error: Object reference not set to an instance of an object
UIPanGestureRecognizer Fading View after a limit
How to run a function when tableviewcell is selected (for example, update UIImageView when cell is pressed)
Alamofire called twice - Swift
'AppDelegate' does not conform to protocol 'GIDSignInDelegate'
Set color of text in status bar it is not working (swift 3 - iOS 10)
Move the annotation on Google Map like Uber iOS application in Swift?
i want to cache my webview content to load it faster SWIFT3
Swipe to back navigation not working for Localization app
Appium Desktop could not start new session with iOS
Get duration of video with AVFoundation
How do I make my UICollectionView return 3 columns with 1 pixel spacing between them just like instagram? Swift
Failed to obtain a cell from its dataSource - storyboard and code
Core Data Concurrency Debugging
Need help linking mapKit annotation to CollectionView in Swift
Add New data from Bottom in TableView

Categories

HOME
odoo-10
vb.net
codenameone
google-cloud-dataproc
angular-mdl
webdriver-io
pyusb
ceph
base
prestashop-1.7
zebble
cobol
yii2-advanced-app
jquery-jtable
vscode-settings
git-svn
stackexchange-api
silk-performer
nxbre
spark-graphx
zos
symbolic-math
precision
google-oauth2
memorystream
valueinjecter
feedly
skyscanner
evercookie
server-sent-events
haxm
advanced-installer
data-science
ecdsa
rights-management
partition
runge-kutta
compass-lucene
angular2-seed
edeliver
quicksand
autofocus
gulp-babel
psycopg2
name-mangling
multisite
tpl-dataflow
cmsmadesimple
flying-saucer
assembly-references
blocking
plotrix
wxhaskell
sqlite-net
android-alertdialog
vistadb
error-correction
android-chips
measurement-protocol
data-fitting
network-traffic
qlpreviewcontroller
webmail
viewengine
cucumber-java
dual-table
sqlj
linqtocsv
hypervisor
gem
google-swiffy
smarty2
wintersmith
cordova-cli
isql
simpleadapter
imake
concurrentdictionary
iphone-privateapi
subdirectory
aps
image-scaling
magic-unipaas
asciiencoding
confirmation
jquery-mobile-popup
android-lru-cache
couchrest
deap
sysadmin
flash-cs4
repeating
firebird2.1
globbing
dynamic-usercontrols
ria
force.com
jscience
server.mappath
intel-8080
stumbleupon
blackberry-os-v5
replay
servletunit
seam-conversation
graceful-degradation
user-testing

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