ios - UIPickerView is Selecting the Wrong Row-Swift -


so have uipickerview isn't working way want to. works correctly 3/4 of time, other 1/4 doesn't.

 func numberofcomponentsinpickerview(pickerview: uipickerview) -> int {     return 1 }  func pickerview(pickerview: uipickerview, numberofrowsincomponent component: int) -> int {     return listsarray.count  }  func pickerview(pickerview: uipickerview, viewforrow row: int, forcomponent component: int, reusingview view: uiview!) -> uiview {     activequizplace = row     var pickerlabel = uilabel()     pickerlabel.textcolor = uicolor.whitecolor()     pickerlabel.text = listsarray[row]     pickerlabel.font = uifont(name: "georgia", size: 22)     pickerlabel.textalignment = nstextalignment.center     return pickerlabel } 

the listsarray contains 5 items(which strings). rows 0-2 work correctly 100% of time. when row 3 selected says row 1 was, , when row 4 selected says row 2 was. think problem has last function have controls uipickerview. copied code website way change color , font of text. before using function never had problem it, or @ least never noticed one. side note: using xcode 6.3.2

i need way picker view work correctly, able change font , color. love i've been looking answers online 2 hours , can't figure out i'm doing wrong, in advance!

i think need remove line activequizplace = row code have shown , add function below.

func pickerview(pickerview: uipickerview, didselectrow row: int, incomponent component: int) {     activequizplace = row } 

the function using not called index user selects, called index system needs drawing views.

the suggested function should 1 after (hopefully).


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -