uipickerview

UIPickerView as inputView of UITextField

非 Y 不嫁゛ 提交于 2019-11-26 23:06:15
问题 I've read a lot about how I can use a UIPickerView as the inputView of my UITextField . The thing is, I am able to call the UIPickerView when I tap on the UITextField . However, my app always loads with the UIPickerView shown. I have already tried changing the myownpickerview.hidden = YES; in viewDidLoad , but this causes problems when I click on the UITextField . It won't show up, and if I click multiple times, the debugger shows that there would be an error. Can anyone point me in the right

Overriding highlighted selection in UIPickerView

不问归期 提交于 2019-11-26 22:22:30
问题 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. 回答1: You need to make sure your custom view has the following

Show data in UIPickerView second component based on first component selection

家住魔仙堡 提交于 2019-11-26 21:26:06
问题 I am using a picker with two components. I want if I select a row in first component on the basis of selected component it shows the value of the corresponding data. As Picker is showing that England has corresponding clubs when England is selected. I want to do same for the other countries. But I am not getting which approach to follow. Here is my code: - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView { return 2; } - (NSInteger)pickerView:(UIPickerView *

Hiding/ Showing UIPickerView

霸气de小男生 提交于 2019-11-26 20:15:18
问题 I Have an a touchesEnded event that checks for when a UITextField is pressed. What I would like it to do is is hide/show a UIPickerView. How can this be done? - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch = [[event allTouches] anyObject]; if (CGRectContainsPoint([self.textField frame], [touch locationInView:self.view])) { NSString * error = @"Touched the TextField"; UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Selection!" message:error

Change UIPickerView background

笑着哭i 提交于 2019-11-26 20:09:57
I want to change the border color of a UIPickerView. I do not see a tint property for the UIPickerView. Is there any way this could be done? Or a workaround? Thanks. Ed Marty If you just want a workaround, take a screen shot in the simulator, open it in photoshop, crop it to just the UIPickerView area, make the center transparent, apply whatever tint you want, add that image to your project, and add it as a UIImageView on top of the UIPickerView. You could also mask the component. With a bit fiddeling you can get the size of the component and cut it out with following code: CALayer* mask = [

Fixed labels in the selection bar of a UIPickerView

牧云@^-^@ 提交于 2019-11-26 19:40:09
In the clocks application, the timer screen shows a picker (probably a UIPicker in UIDatePickerModeCountDownTimer mode) with some text in the selection bar ("hours" and "mins" in this case). (edit) Note that these labels are fixed : They don't move when the picker wheel is rolling. Is there a way to show such fixed labels in the selection bar of a standard UIPickerView component? I did not find any API that would help with that. A suggestion was to add a UILabel as a subview of the picker, but that didn't work. Answer I followed Ed Marty's advice (answer below), and it works! Not perfect but

How to change the color of UIPickerView Selector

↘锁芯ラ 提交于 2019-11-26 18:29:30
问题 I am having a UIPicker, I want to change the color of the selector. Is it possible to change the color of the selector? 回答1: I suppose you're dealing with the iPhone SDK? There may be some other frameworks which uses this name, so maybe you can add your tags to include uikit, cocoa-touch or something. Anyway, you can set showsSelectionIndicator of the UIPickerView instance to NO, so it hides the selector. Then you can create a new view with the adjusted selection style, and add it to the

How do you make an UIPickerView component wrap around?

*爱你&永不变心* 提交于 2019-11-26 18:28:56
I would like to show a set of consecutive numbers in a UIPickerView component but have it wrap around like the seconds component of the Clock->Timer application. The only behavior I can enable looks like the hours component of the Timer application, where you can scroll in only one direction. It's just as easy to set the number of rows to a large number, and make it start at a high value, there's little chance that the user will ever scroll the wheel for a very long time -- And even then, the worse that will happen is that they'll hit the bottom. - (NSInteger)pickerView:(UIPickerView *

How to use two UIPickerViews in one view controller?

a 夏天 提交于 2019-11-26 18:13:13
问题 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

How to change color of selected row in UIPickerView

谁都会走 提交于 2019-11-26 16:42:15
问题 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