Questions tagged [uipickerviewdatasource]

UIPickerViewDataSource is an iOS protocol for defining methods instructing a UIPickerView how many components and rows it should display.

UIPickerViewDataSource is an iOS protocol defining methods instructing a UIPickerView how many components and rows it should display. A picker view can have 1 or more components (the wheels in a slot-machine metaphor), each with an independent number of rows (the writing on the wheels). Two methods return these values:

  • numberOfComponentsInPickerView: - returns the number of wheels
  • pickerView:numberOfRowsInComponent: - returns the number of rows for a given wheel

For more information, please refer to the Apple Documentation for UIPickerViewDataSource.

49 questions
39
votes
5 answers

Type "myViewController" does not conform to protocol UIPIckerDataSource in Swift

I just create a new class in Swift, it's called myViewController and it's a UIViewController. Now I'm trying to make it a UIPickerViewDelegate and DataSource but i got a strange error import UIKit class myViewController: UIViewController,…
r4id4
  • 5,877
  • 8
  • 46
  • 76
11
votes
2 answers

Xcode 8 / Swift 3 : Simple UIPicker code not working

I have protocols: class ViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource { I have data: let muteForPickerData = ["minute(s)","hour(s)"] In viewDidLoad I have: muteForPicker.delegate = self muteForPicker.dataSource =…
Kashif
  • 4,642
  • 7
  • 44
  • 97
9
votes
1 answer

UIPickerView with "external" DataSource and Delegate in Swift

I have two different UIPickerViews in my View. They work great when I set the dataSource and the delegate to the View they are hosted in via the storyboard, but when I try to do that via code as described below, it does not work. Both pickers shall…
8
votes
3 answers

UIPickerView: NSAttributedString not available in iOS 7?

It seems the UIPickerView no longer supports the use of NSAttributedString for picker view items. Can anyone confirm this? I found NS_AVAILABLE_IOS(6_0) in the UIPickerView.h file, but is this the problem? Is there a way around this, or am I out of…
Rob
  • 1,045
  • 13
  • 28
8
votes
3 answers

Add image icon to a UIPickerView row

I have looked and looked on the net and not found much on this! I would like to know how you put images in a UIPicker so that each of the rows have a different image. #import "ViewController.h" @interface ViewController () @end …
Dave
  • 81
  • 1
  • 1
  • 2
3
votes
1 answer

set a component of UIPickerView as a separator

I created a decimal number UIPickerView. I want the second component which is just a constant dot string (.) became as a separator, I mean : 1) It doesn't move 2) Its width is smaller than other components 3) Its color is different in comparison…
Soheil Novinfard
  • 1,358
  • 1
  • 16
  • 43
3
votes
2 answers

UIPickerView text scale in not enough

I need to implement UIPickerView like this: But default implementation gives this: I used this UIPickerDatasourse method: func pickerView(pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusingView view: UIView?) ->…
Paul T.
  • 4,938
  • 7
  • 45
  • 93
3
votes
3 answers

UIPickerView selectRow not working as expected

I've created a UIPickerView which has two components, the first component (A) has a fixed number of rows set at 13. The other component (B) has a variable number of rows which is dependant on the row selected in (A). When loading the UIPickerView I…
user843337
2
votes
0 answers

UIPickerViewDataSource vs UIPickerViewDelegate logic

Why aren't methods like – pickerView:titleForRow:forComponent: part of UIPickerViewDataSource instead of UIPickerViewDelegate as it is currently? After all, the titles are data... This seems very inconsistent to me. For example,…
2
votes
1 answer

Using UIPickerView as a DatePicker with minimum and maximum possible selections

Honestly, I have never really done this so I'm very much lost here. I have an app, presenting a UIPickerView with days: hours: minutes to the user. I have to make sure that the minimum selected time is 10 minutes and maximum selected time is 7…
Dani
  • 3,427
  • 3
  • 28
  • 54
2
votes
2 answers

How to Scroll to Specific Row in UIPickerView In iOS Swift 3

I have a UIPickerView with values 0...250. There is 2 Components in UIPickerView. In First component i am displaying these values. but i want to detect scrolling method of the UIPickerView. because when pickerView appears the value I would like to…
2
votes
0 answers

Multiple UIPickerViews Dependent On Previous Selection With Large Datasource

I need to be able to select a village in Thailand, based first off of Province, Region, District, and then finally selecting the village. Basically you select the Province first, and that in turn shows all the Regions in that Province, and so on…
user717452
  • 33
  • 14
  • 73
  • 149
2
votes
2 answers

UIPickerView pickerView:titleForRow:rowforComponent method not called

I have a UIPickerView in my storyboard. The UIViewController containing it has interface declarations set @interface ContactDetail : UIViewController
2
votes
2 answers

PickerView invisible against a black background

This might be a silly and really simple question, but I've not been able to solve it. I have a view controller with a black background onto which I have placed a PickerView control. I have set the delegate and datasource and have confirmed they are…
2
votes
3 answers

UIPickerView Not Displaying data in picker but displaying in nslog

The problem is that picker is not displaying any data but the data is present in the background as i scroll the empty pickerview in nslog it displays the data. So data is populating but not displaying in uipickerview. Thanks in advance Here is the…
Ali
  • 525
  • 12
  • 24
1
2 3 4