is there a uipickerview delegate method like scrollviewDidScroll?

Use following method, – (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { // put your logic here. } Above method is from UIPickerViewDelegate, If user selects any element using pickerview, this method is automatically triggered. Hope it helps to you. Edit : I think you should use following method for detecting – in which direction user is scrolling … Read more

Objective C implementing a UIPickerView with a “Done” button

The easiest way to do it is to model it in Interface Builder. It is a UIView containing a UIToolbar and a UIPickerView. Then create an outlet for the UIView and connect it. If you then have a UITextField you can assign your custom view to its inputView property. [self.textField setInputView:self.customPicker]; Alternatively you can add … Read more

display done button on UIPickerview

You can use this code, UIToolbar *toolBar= [[UIToolbar alloc] initWithFrame:CGRectMake(0,0,320,44)]; [toolBar setBarStyle:UIBarStyleBlackOpaque]; UIBarButtonItem *barButtonDone = [[UIBarButtonItem alloc] initWithTitle:@”Done” style:UIBarButtonItemStyleBordered target:self action:@selector(changeDateFromLabel:)]; toolBar.items = @[barButtonDone]; barButtonDone.tintColor=[UIColor blackColor]; [pickerView addSubview:toolBar]; //(or)pickerView.inputAccessoryView = toolBar; and set button action method for changeDateFromLabel: -(void)changeDateFromLabel:(id)sender { [[your UI Element] resignFirstResponder]; }

How do I change the color of the text in a UIPickerView under iOS 7?

There is a function in the delegate method that is more elegant: Objective-C: – (NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component { NSString *title = @”sample title”; NSAttributedString *attString = [[NSAttributedString alloc] initWithString:title attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}]; return attString; } If you want to change the selection bar colors as well, I found that I had to add 2 … Read more

Xcode 8 / Swift 3 : Simple UIPicker code not working

UIPickerViewDataSource method numberOfComponentsInPickerView is changed in Swift 3 like this that is the reason you are getting this error. func numberOfComponents(in pickerView: UIPickerView) -> Int { return 1 } func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { return muteForPickerData.count } func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { … Read more

How do you shrink a UIPickerView on the iPhone?

Actually, you can slightly shrink the whole UIPickerView by applying an affine transform to an enclosing view. For example: CGSize pickerSize = [pickerView sizeThatFits:CGSizeZero]; pickerTransformView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, pickerSize.width, pickerSize.height)]; pickerTransformView.transform = CGAffineTransformMakeScale(0.75f, 0.75f); [pickerTransformView addSubview:pickerView]; [self.view addSubview:pickerTransformView]; [pickerTransformView release]; will scale a picker to 75% of its original size by placing it … Read more

UIPicker detect tap on currently selected row

First, conform the class to the UIGestureRecognizerDelegate protocol Then, in the view setup: UITapGestureRecognizer *tapToSelect = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tappedToSelectRow:)]; tapToSelect.delegate = self; [self.pickerView addGestureRecognizer:tapToSelect]; And elsewhere: #pragma mark – Actions – (IBAction)tappedToSelectRow:(UITapGestureRecognizer *)tapRecognizer { if (tapRecognizer.state == UIGestureRecognizerStateEnded) { CGFloat rowHeight = [self.pickerView rowSizeForComponent:0].height; CGRect selectedRowFrame = CGRectInset(self.pickerView.bounds, 0.0, (CGRectGetHeight(self.pickerView.frame) – rowHeight) / 2.0 ); … Read more