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

iOS UIButton near screen edge not respond to tap normally
Xcode view mode settings
Set Title to TableViewController - Beginner
login view controller and main tab bar controller
How get the value from NSDictionary with JSON
issue with passing array of dictionaries into function
Remove push notification history entries from Parse
Getting same values in uitableview
UISearchController change 'Cancel' button title
How to make the pageControl swipe effect? The scroll view slides continuously so far
XCode Projects not being pulled from source control correctly?
Having issues with UILabel not updating like it should
How to Fetch date and time from a formatted string in iOS
Determine where physicsbody is touching
Document Provider how to use?
What is the best way to create a reusable top menu with a dropdown list

Categories

HOME
graph
f#
web-services
blogs
jsonschema
tsql
vsix
format
c++14
jbpm
range
zipfile
overloading
marketplace
threadpool
apache-kafka-streams
records
syswow64
ssrs-2008
gas
teamcity-9.0
man
powershell-v2.0
spark-graphx
urlrewriter.net
bitcode
ratchet-2
precision
addthis
sumifs
iar
android-button
editorconfig
pmd
charts.js
gecko
blockui
imagemapster
nio
apartment-gem
psychopy
consistency
monogame
angularjs-routing
couchbase-lite
sql-insert
rating-system
ewsjavaapi
azure-cdn
laravel-routing
sshd
harvest-scm
haste
catalina
gpt
dr-memory
agile-processes
mysql-notifier
logstash-jdbc
bootstrap-slider
evaluate
agents-jade
cufft
namenode
rabbitvcs
jca
storage-duration
clientid
fab
linqtocsv
sample-data
push-api
crosswalk
axlsx
node-orm2
maven-cargo
byte-order-mark
ratingbar
symfony-2.5
zeroclipboard
django-supervisor
bonecp
nine-patch
scala-pickling
re2c
xcache
alternate-data-stream
google-provisioning-api
ariatemplates
rgba
quilt
ed
ember-router
datatemplate
jboss-cache
spquery
xml-database
sqlitemanager
gendarme
crc-cards
shareware
greensoftware
graceful-degradation

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