uipickerview

UIPickerView自定义显示视图

被刻印的时光 ゝ 提交于 2019-11-30 14:32:33
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return 1; } - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { return self.data.count; } - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { return self.data[row]; } - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { } - (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component { return 70; } - (UIView *)pickerView:

iOS7 UIPickerView doesn't properly display custom views with images

為{幸葍}努か 提交于 2019-11-30 10:04:22
This issue started happening in iOS7 with the new UIPickerView controller. To use images in your UIPickerView controller you must use the delegate method to return an image: pickerView:viewForRow:forComponent:reusingView: The problem is that the screen subsequently exhibits all kinds of strange behavior - the image views disappear as you move your finger up and down the control. This is a solution posted on a dev forum which works as of iOS 7.0.2: - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { // self

Customizing UIPickerView (background and spacing)

霸气de小男生 提交于 2019-11-30 09:48:05
I would like to change the white background in a UIPickerView to an image of my own. Is this possible? Also, I have managed to get my UIPickerView to scroll horizontally instead of vertical. Now, I would like to know if there is any way to adjust the spacing between two rows of the picker view? I have attached an image to show what I mean. This is my code: - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. arrayDays = [[NSMutableArray alloc] init]; [arrayDays addObject:@"ONSDAG"]; [arrayDays addObject:@"TORSDAG"]; [arrayDays addObject:@

Multiple UIPickerViews

南笙酒味 提交于 2019-11-30 09:37:26
问题 I have a dilemma, I have two UIPickerViews which "show" when two distinct views load. I started with one UIPickerView and was able to get that up and running by loading the array and all the other UIPickerView actions within the ViewController. I thought it would be as simple as copy/pasting the same methods for the new UIPickerView , but just changing the variable names, also within the same UIViewController . Problem is - both UIPickerView are showing the same data set in the drop down ? Am

UIPickerView won't allow changing font name and size via delegate's `attributedTitleForRow…`

ⅰ亾dé卋堺 提交于 2019-11-30 08:02:34
I use the following func to change the font color and font size, the color works but the font name and font size refuse to work. func pickerView(pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? var myTitle = NSAttributedString(string: titleData, attributes: [NSFontAttributeName:UIFont(name: "Arial-BoldMT", size: 45)!, NSForegroundColorAttributeName:UIColor.whiteColor()]) any help? Thx. I have a another option may be it helpfull for you.. Do all work that need for normal picker view : for more help UIPickerView make in Swift iOS Now

How to change UIPicker Color ? iPhone

陌路散爱 提交于 2019-11-30 07:38:51
I have observed that UIPicker always remains in black color, Is there any way to change the color of UIPicker & it's Selection Indicator? Thanks for helping me. I assume all you want to change is the color of the border of the picker, not of the region in the center with which the user interacts. In this case, do the following: Create 4 "cover" UIViews and add them directly to the UIPicker, as in: [picker addSubview: coverView]; Position these views over the top, bottom, left and right sides of the picker border. (You will need to experiment with sizes.) Set the backgroundColor of the

Disable particular row value in UIPickerView

五迷三道 提交于 2019-11-30 07:34:05
问题 I am trying to disable particular row in pickerView. I have an array of strings for pickerView. I am appending values in array1 when user selects particular row. After that I want to do that when user again opens pickerView if array1 has values of array, pickerView's that value should be disabled. How can I do that? 回答1: Option 1: Disabling an element You can give the title a greyed out style with the method pickerView:attributedTitleForRow:forComponent: Then you can change to a defaut value

How can I get a check mark beside UIPickerView labels?

心不动则不痛 提交于 2019-11-30 07:26:21
The UIPickerView that appears in Safari has a check mark beside the current choice. Is there a built-in way to get this, or do I have to program it up myself? If I do have to create it, can anyone point me to some code to do this? Thanks You need to implement -pickerView:viewForRow:forComponent:reusingView: from the UIPickerViewDelegate. You have to create a view, that contains a UIButton with the checkmark image, and return it from -pickerView:viewForRow:forComponent:reusingView: Here is some official sample code for customizing UIPicker view: http://developer.apple.com/library/ios/

UIPickerView with NSDictionary

Deadly 提交于 2019-11-30 07:12:32
I am a .NET programmer and new to Objective C. I am trying to make a UIPickerView which acts like a .NET dropdownlist. User sees the list of text and selects one and the selected value (which is the ID) is used in code. I have been browsing for almost half a day trying to figure this out. I could add a regular PickerView with list of strings, picker view with mulitple components and picker view with dependent components none of which seems to answer my query. Please help. You can use a NSDictionary as a data source for UIPickerView but if you have a custom NSObject that already contains the

Multiple sources for UIPickerView on textfield editing

风格不统一 提交于 2019-11-30 07:02:33
问题 What i have so far is @synthesize txtCountry,txtState; int flgTextField; - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField { [pickerView reloadAllComponents]; // Make a new view, or do what you want here if(textField == txtCountry || textField == txtState){ flgTextField = textField.tag; [UIView beginAnimations:nil context:NULL]; //[pvState setFrame:CGRectMake(0.0f, 199.0f, 320.0f, 216.0f)]; [UIView commitAnimations]; return NO; } else { return YES; } } - (NSInteger