uipickerview

UIPickerViewDelegate Xcode 8 Swift 3

喜欢而已 提交于 2019-12-06 00:31:52
My code is: class ViewController: UIViewController,UIPickerViewDelegate, UIPickerViewDataSource { @IBOutlet weak var picherview: UIPickerView! var prodotti = ["AAAAA", "VVVV", "CCCC"] override func viewDidLoad() { super.viewDidLoad() self.picherview.dataSource = self self.picherview.delegate = self // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } func numberOfComponents(in pickerView: UIPickerView) -> Int { return 1 } func pickerview( _ :

Change color of selectedRow in UIPickerView, also when rolling

馋奶兔 提交于 2019-12-05 23:49:49
I have to change the color of the selected row in a UIPickerView . I did managed to change the color, i know that the question already have several replies, anyway those do not satisfy me: with those implementation, the animation of the pickerview is glitchy and i don't like it. This is the code of the current solution func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView { var label: UILabel if view == nil { label = UILabel() } else if view is UILabel { label = view as! UILabel } else { label = UILabel() } let title:

Why UIPickerView is semi transparent

牧云@^-^@ 提交于 2019-12-05 21:59:08
Why UIPickerView is not %100 opaque? When I set text color to white and put UIPickerView on a red background, the UIPickerView items have a reddish white text color. I tried custom views using viewForRow , but still no effect. How can I set opacity of UIPickerView to %100? In IB it's alpha is 1 but actually in runtime it isn't Please try this delegate and make your own customize view and return it. -(UIView *)pickerView:(UIPickerView *)pickerView viewForRow: 来源: https://stackoverflow.com/questions/39325827/why-uipickerview-is-semi-transparent

UIPickerView crashes app when user is spinning components at the same time

旧巷老猫 提交于 2019-12-05 17:53:40
I've got really unbearable issue with UIPickerView. There're 2 components: first one with food categories, and second with foods inside each category. I've got proper arrays with foods, which looks like: ViewController.h @property (strong, nonatomic) NSArray *leftPickerDataSource; @property (strong, nonatomic) NSArray *vegetablesDataSource; @property (strong, nonatomic) NSArray *eggsDataSource; @property (strong, nonatomic) NSArray *pastaDataSource; @property (strong, nonatomic) NSArray *riceDataSource; @property (strong, nonatomic) NSArray *meatDataSource; ViewController.m ... @implementation

Multi-Component Picker (UIPickerView) in SwiftUI

穿精又带淫゛_ 提交于 2019-12-05 17:20:50
I'm trying to add a three-component Picker (UIPickerView) to a SwiftUI app (in a traditional UIKit app, the data source would return 3 from the numberOfComponents method), but I can't find an example of this anywhere. I've tried adding an HStack of three single-component Pickers, but the perspective is off from what it would be if they were all part of a single Picker. Updated answer in pure SwiftUI - in this example the data is of type String . Tested on Xcode 11.1 - may not work on previous versions. struct MultiPicker: View { typealias Label = String typealias Entry = String let data: [

Using UIPickerView with multiple components in swift

ⅰ亾dé卋堺 提交于 2019-12-05 11:39:16
Hi there I have been trying to get this working for ages with no success so apologies if this seems easy for you guys. I want to use a 3 wheel UIPickerView - The 1st wheel didSelectRow value will be used to change the array for the remaining two wheels but they will be the same as it is a conversion app. It seems to throw me an error up when populating the wheels saying that Anyobject is not identical to String. I cannot see anything wrong but I know it is something basic I have missed. Any pointers would be much appreciated. Motty. // ViewController.swift // picker test import UIKit class

How to give this picker view a datasource

南笙酒味 提交于 2019-12-05 10:38:29
Here I am adding a pickerview programaticly - (void)viewDidLoad { [super viewDidLoad]; CGRect pickerFrame = CGRectMake(0,280,321,200); UIPickerView *myPickerView = [[UIPickerView alloc] init]; //Not sure if this is the proper allocation/initialization procedure //Set up the picker view as you need it //Set up the display frame myPickerView.frame = pickerFrame; //I recommend using IB just to get the proper width/height dimensions //Add the picker to the view [self.view addSubview:myPickerView]; } But now I need to actually have it display content and somehow find out when it changes and what

iOS6 UIPickerView memory leak issue.

ε祈祈猫儿з 提交于 2019-12-05 07:53:58
I was getting this memory leak: [UIPickerTableViewTitleCell initWithStyle:resuableIdentifier]; and NSConcentrateMutableAttributedString. Issue was that I had not implemented this delegate. After implementing this now memory leaks goes away. May be this information helpful for other as I spend mine 16 hours only to figure out this issue. // Do something with the selected row. - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { // Get the text of the row. NSString *rowItem = [NSString stringWithFormat:@" %@",

Change UIPicker color

半世苍凉 提交于 2019-12-05 07:27:05
How can I change the color of my picker? I don't wish to change the font or the text. My picker is populate and works exactly how I want it, what I want to do is change the color from black to my custom white. Youri Nooijen Take a look at: http://makeapppie.com/tag/uipickerview-in-swift/ If you want to change your title color of each element you could implement: func pickerView(pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? { let titleData = pickerData[row] var myTitle = NSAttributedString(string: titleData, attributes:

How to Change Color selected Picked value from pickerview?

我与影子孤独终老i 提交于 2019-12-05 04:56:00
问题 pickerArray = [[NSArray arrayWithObjects:@"20", @"40", @"60",@"80", @"100", @"120", @"140", @"160", @"180", @"200",nil] retain]; - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { //On Selecting the component row if (component == 0) { } else if (component == 1) { [quantityPickerDelegate didChangeLabelText:[pickerArray objectAtIndex:row]];// delegate passing the selected value pickerLabel.textColor = [UIColor colorWithRed:0.0745 green:0