uipickerview

How to change color of selected row in UIPickerView

扶醉桌前 提交于 2019-11-27 14:20:44
Ok, maybe I'm missing something really simple and I apologize if that's the case, however, I've googled every permutation of the title and have not found! So this is simply what I want to do: change the background color of the label I'm using as the row view in a 2 component pickerview when that row has been selected. So I thought this would work: if (row == [pickerview selectedRowForComponent]) viewlabel.backgroundColor = redcolor; but this doesn't work. It seems to arbitrarily choose which row to color and sometimes even give a bad access error. I've tried all different clauses to no effect!

iOS 7.1 UITapGesture not working with UIPickerView

廉价感情. 提交于 2019-11-27 13:27:53
We are using a UIPickerView to allow a user to select from a list of options. We are adding UIPickerView as a subview of a container UIView. We are then adding a UITapGestureRecognizer to the container UIView . The UITapGestureRecognizer is being used to dismiss the picker via removing it's super view. In iOS 7.0 and previous versions, this was working as expected. However, in iOS 7.1 this set up is no longer working in the sense that UITapGestureRecognizer is not recognizing the tap and calling the selector specified in the action (dismissing the picker view and container view). code is below

Custom UIPickerView with Custom Background color

Deadly 提交于 2019-11-27 13:12:43
问题 I have created a sample picker-view which will display some details. Setting the Background color using: _pickerView.backgroundColor = [UIColor redColor]; doesn't seems to be working . But I wish I could create a picker view like the below image What I was trying to do is , the entire PickerView background color should not be white, it should fill with the UIColor which I am giving. Is that possible?? How it can be done ?? 回答1: Addition to Nina's answer, below are some of the good custom

Overriding highlighted selection in UIPickerView

丶灬走出姿态 提交于 2019-11-27 12:56:45
I have a custom UIPickerView where I use: -(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view to populate the picker with UILabels . Is there a way to disable the behavior of highlighting the selected row when touched? I think this is a property of the underlying UITableViewCell inherent in the UIPickerView and I can't find a way to change it. Doug Barth You need to make sure your custom view has the following properties: It needs to be sized to the same dimensions that the UIPickerView expects based on your

How to use two UIPickerViews in one view controller?

别说谁变了你拦得住时间么 提交于 2019-11-27 12:43:16
I have two UIPickerController s in one view controller. I can get one to work, but when I add a second, my app crashes. Here is the code I use for one picker view: import UIKit class RegisterJobPosition: UIViewController, UIPickerViewDelegate { @IBOutlet weak var positionLabel: UILabel! var position = ["Lifeguard", "Instructor", "Supervisor"] override func viewDidLoad() { super.viewDidLoad() } func numberOfComponentsInPickerView(PickerView: UIPickerView!) -> Int { return 1 } func pickerView(pickerView: UIPickerView!, numberOfRowsInComponent component: Int) -> Int { return position.count } func

How do I make a UIPickerView in a UIActionSheet

杀马特。学长 韩版系。学妹 提交于 2019-11-27 12:35:58
问题 Just want to know how I would make a UIPickerView in a UIActionSheet with a simple array. Ok well I actually found out how to put it into an action sheet but I like your way better because it applies more to my app, thanks, but I want to also know how put the options into the UIPickerView, I am just hung up on that part of that. I already have an array with the colors: red, green, blue, yellow, black, etc in it but I want to know how to put that into the pickerview if I have already used

How do I rewrite the UIDatePicker component?

余生颓废 提交于 2019-11-27 12:24:09
问题 I've noticed that the UIDatePicker doesn't work with NSHebrewCalendar in iOS 5.0 or 5.1. I've decided to try and write my own. I'm confused as to how to populate the data and how to maintain the labels for the dates in a sane and memory efficient manner. How many rows are there actually in each component? When do the rows get "reloaded" with new labels? I'm going to give this a shot, and I'll post as I find out, but please post if you know anything. 回答1: First off, thanks for filing the bug

Swift: How to set a default Value of a UIPickerView with three components in Swift?

[亡魂溺海] 提交于 2019-11-27 12:02:55
问题 How do I set the starting row of the picker view in Swift? I see there is a code for Objective C, but I don't understand it. If anyone could explain how I can translate the Objective C code into Swift that would also be fantastic ! Thanks 回答1: This is the code I have used in one of my apps: // Declare the outlet to the picker in your storyboard @IBOutlet var myPicker: UIPickerView! //... override func viewDidLoad() { //... myPicker.selectRow(row, inComponent: 0, animated: true) } Obviously,

Show UIPickerView text field is selected, then hide after selected

拥有回忆 提交于 2019-11-27 11:57:16
I am trying to create a text box that when it is selected a UIPickerView opens up with choices to select from. Once selected, the UIPickerView hides and the selected item is displayed in the text box. I tried different pieces of code I found online but I just can't get it to work. If someone can suggest a complete code for this or tell me what I am doing wrong in my code, that would be super awesome. Thanks so much. Here is my code: @IBOutlet var textfieldBizCat: UITextField! @IBOutlet var pickerBizCat: UIPickerView! = UIPickerView() var bizCat = ["Cat One", "Cat Two", "Cat Three"] override

How to set a default Value of a UIPickerView

安稳与你 提交于 2019-11-27 10:13:52
问题 I have a problem with my UIPickerView. I have 3 values in it EU AP and NA. When I start the app EU seems to be selected but when I make a NSLog(@"%@", [regions objectAtIndex:row]); I only get back (null) , now when I touch the UIPickerView the EU value is selected and I get "EU" back from a NSLog. My question is: How can I define a default value which is selected (not only the label) when the user only starts the app and touches nothing. Edit: Here is my code to get the selected item: #pragma