Questions tagged [uipickerviewdelegate]

The delegate of a UIPickerView object must adopt this protocol and implement at least some of its methods to provide the picker view with the data it needs to construct itself.

The delegate of a UIPickerView object must adopt this protocol and implement at least some of its methods to provide the picker view with the data it needs to construct itself. On UIPickerViewDelegate, you can find the following methods:

Setting the Dimensions of the Picker View

– pickerView:rowHeightForComponent:

– pickerView:widthForComponent:

Setting the Content of Component Rows

The methods in this group are marked @optional. However, to use a picker view, you must implement either the pickerView:titleForRow:forComponent: or the pickerView:viewForRow:forComponent:reusingView: method to provide the content of component rows.

– pickerView:titleForRow:forComponent:

– pickerView:attributedTitleForRow:forComponent:

– pickerView:viewForRow:forComponent:reusingView:

Responding to Row Selection

– pickerView:didSelectRow:inComponent:

39 questions
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…
3
votes
2 answers

Can't get UIPicker text coloring to stick

I'm trying to get a UIPicker that shows the selected row with green text. I use the pickerView:viewForRow:forComponent:reusingView: method to create a UILabel for it: - (UIView*) pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row…
Travis Griggs
  • 21,522
  • 19
  • 91
  • 167
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
0 answers

Removing UIPickerView when button is pressed swift

How can I dismiss a uipickerview view using swift? I have created the UIPickerView in UITableView as I want it to be populated with the elements in the UITableView. Then I have just a UIButton appear on the screen. I want it so that the UIPickerView…
kitchen800
  • 197
  • 1
  • 12
  • 36
2
votes
2 answers

UIPickerView selectedRowInComponent:0 always return zero first when I try to set data in second component

I'm new to iOS programming. Recently, I'm trying to make a UIPickerView as an inputView in UITextfield. The data in UIPickerView is about all the iOS built-in fonts. So I want to make two components in UIPickerView: the first is familyType, and the…
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
1 answer

Why doesn't attributedTitleForRow get called with a UIPickerView?

As per the documentation, picker views prefer to use attributedTitleForRow over titleForRow. If the preferred returns nil, the picker view falls back to titleForRow. I'm implementing both methods, and attributedTitleForRow never gets called. Even…
ArielSD
  • 829
  • 10
  • 27
2
votes
2 answers

First iOS app in Swift - Question marks in UIPickerView

I'm working on my first Swift ios application. Can't get data from pickerData into my picker, but I only get question marks instead of real values. I guess it's something to do with delegate, but not sure what wrong. import UIKit import…
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
1
vote
1 answer

Cannot Assign UIPickerView Delegate or DataSource

For some reason I cannot assign UIPickerView's data source or delegate to my NSObject. I have an NSObject which extends UIPickerViewDataSource and UIPickerViewDelegate class STRepeatPicker: NSObject, UIPickerViewDataSource, UIPickerViewDelegate { …
1
vote
1 answer

Detect when UIPickerView starts changing / moving

I'm trying to react to the event that a UIPickerView started moving (not when the row was already selected). I have searched throughout the delegate methods, and none helped. I also tried to register a notification, but couldn't figure out any that…
Jacobo Koenig
  • 11,728
  • 9
  • 40
  • 75
1
vote
0 answers

UIPickerView Selected Row Title Design Not Changing While Row Value Equals to 1

I have 2 uipickerviews for selection of hour and minute values. When I wanted to select default values for both of them if selectedRow = 1 title color becomes gray(this means row is not selected) and this issue happens only at first load(when…
1
vote
1 answer

UIPickerView Jitter

I have a UIPickerView and a UILabel, separate from each other. When the user selects a row in the UIPickerView, I change the UILabel text using the delegate function: func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent…
user5932360
1
vote
2 answers

UIPickerView delegate methods not being called even though delegate has been set after [[UIPickerView alloc] init]

Title says it all really I have a method that is called to create the UIPickerView and in the same view controller as the delegate methods. The view controller implements the UIPickerViewDataSource and UIPickerViewDelegate protocols //…
1
vote
3 answers

UIPickerView - remove curvature and add text

I'm trying to create a UIPicker where I can select minutes and seconds. Here's the code: - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return 2; } - (NSInteger)pickerView:(UIPickerView *)pickerView…
soleil
  • 12,133
  • 33
  • 112
  • 183
1
2 3