2 Replies
      Latest reply: Feb 7, 2017 2:42 PM by eskimo RSS
      Nitrouspeed Level 1 Level 1 (0 points)

        So I am not a pro at swift or programming in general but I know most of the basics to it all. I am currently making a project for my Computer Science class and decided to use the "Picker View" in it, it took me a while to understand how to use the pickerData and Delegates, but once I figured it out, I found that after building, when I touch my Picker in the simulator, everything else pauses until the Picker is done moving. In my app, my timer is very important and can't have it pause when the picker is being used. Can someone please explain why this is happening?

         

             class viewcontroller: UIPickerDataSource, UIPickerDelegate

             IBOutlet weak var Lap: UIPickerView    

         

            func numberOfComponents(in pickerView: UIPickerView) -> Int {

                return 1

            }

            func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {

                return pickerData.count

            }

            /

            func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {

                return pickerData[row]

            }

            func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {

        • Re: Why does the picker pause other functions in the app?
          Claude31 Level 4 Level 4 (815 points)

          You should run the other task in a different queue and let picker run in UI Queue (mainQueue).

            • Re: Why does the picker pause other functions in the app?
              eskimo Apple Staff Apple Staff (5,995 points)

              I found that after building, when I touch my Picker in the simulator, everything else pauses until the Picker is done moving. In my app, my timer is very important and can't have it pause when the picker is being used. Can someone please explain why this is happening?

              If, by “timer”, you mean Foundation’s Timer type, then it’s possible you could fix this by scheduling the timer in the common modes.  See this post for more.


              Claude31 wrote:

              You should run the other task in a different queue …

              This might be the right answer but it does introduce multithreading to your app, which may be more complexity then you need.

              There’s a great variant of the “two problems” joke:

              Some people, when confronted with a problem, think, “I know, I’ll use threads,” and then two they hav erpoblesms.

              Share and Enjoy

              Quinn “The Eskimo!”
              Apple Developer Relations, Developer Technical Support, Core OS/Hardware
              let myEmail = "eskimo" + "1" + "@apple.com"