uipickerview

Swift - hide pickerView after value selected

独自空忆成欢 提交于 2019-12-07 03:39:56
问题 I have found similar questions about this and their answers were helpful but I am stuck at one last thing. I am trying to get a pickerView to appear when I tap on a field, then when data is selected, I want the pickerView to hide. I am able to get the data from the pickerView to hide, however, there is still a grey rectangle that was behind the pickerView that remains. If I tap on the screen, not on a field or the pickerView, the gray rectangle hides, then reappears when I tap on the next

Change UIPicker color

北慕城南 提交于 2019-12-07 03:38:57
问题 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. 回答1: 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

Default UIPickerView height

安稳与你 提交于 2019-12-06 18:29:48
问题 How can I programatically obtain the default height of an UIPickerView instance, in accordance to the resolution and orientation of the device that the app is currently running on? I would like not to use a hardcoded value for this parameter, in the event that new devices will support different screen resolutions and thus will determine this component to have a different default size. 回答1: The warning that André saw doesn't seem to happen anymore (XCode 4.2; iOS SDK 5.0). If you create it

How can I save a second row of UIPickerView to NSUserDefaults?

本秂侑毒 提交于 2019-12-06 16:35:17
I have pickerView with two rows and I need to save position of both to NSUserDefaults. I have successful saved first row with this code: - (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { NSInteger selectedRow = [thePickerView selectedRowInComponent:0]; [[NSUserDefaults standardUserDefaults] setInteger:selectedRow forKey:@"picker"]; } And I don't get how to add a second one. With this code I bring back the position: -(void)viewWillAppear: (BOOL) animated { NSUserDefaults *pickerViewSelectionDefaults = [NSUserDefaults

How to change the picker rows based on another picker's selection?

那年仲夏 提交于 2019-12-06 14:17:59
问题 I have two pickers - country and region. I need to populate the region picker based on the row selected in the country picker. I have arrays to populate both the pickers. I need some help to change the rows of region picker based on the country picker's selection. Any help would be greatly appreciated. Thanks a lot in advance. 回答1: Ok You have two pickers lets say countryPicker and regionPicker. in the delegate method for UIPickerView add one condition - (NSString *)pickerView:(UIPickerView *

How to get callback from UIPickerView when the selectRow animation is done?

时光怂恿深爱的人放手 提交于 2019-12-06 13:44:32
I have a UIPickerView and I would like to be notified when the selectRow animation is done. I tried the following approach in my view controller which has a reference to the UIPickerView and it won't work: -(void)viewDidLoad { ... [UIPickerView setAnimationDelegate:self]; [UIPickerView setAnimationDidStopSelector:@selector(animationFin ished:finished:context]; ... } - (void)animationFinishedNSString *)animationID finishedBOOL)finished contextvoid *)context { if (finished) { } } Then somewhere in my code, I initiate the animation: [picker selectRow:random() % pickerDataCount inComponent:0

UI Automation Testing: How do I select UIAPickerWheel values?

最后都变了- 提交于 2019-12-06 13:06:31
问题 I've hit a roadblock in trying to write some automated tests for my iPhone app. Judging from the documentation I feel like this should select the first row of the first component of my UIPickerView: var picker = UIATarget.localTarget().frontMostApp().mainWindow().pickers()[0]; var aWheel = picker.wheels()[0]; var someVals = aWheel.values(); aWheel.selectValue(someVals[0]); But instead I get the following error, logged in Instruments: Exception raised while running script: - selectValue

UIPickerView - using custom views for multi-line rows - need layout advice

夙愿已清 提交于 2019-12-06 11:25:06
问题 I have a UIPickerView which will display a list of items for the user. I'd like each item to be presented as multiple lines of text using a different font size for each line. A rough mockup is shown below. This will allow presenting more text than can fit in the single line of the default UIPickerView. bdesham pointed me towards using the pickerView:viewForRow:forComponent:reusingView in the delegate for the UIPickerView. This seems to be the way to go as it'll let me provide my own custom

Populating UIPickerView with Core Data objects using Swift

爷,独闯天下 提交于 2019-12-06 11:23:04
I am trying to populate an UIPickerView with Core Data objects in a Swift app. For now, I am getting a picker view with 4 rows (there are 4 objects in the Core Data entity). My issue is that all 4 row titles are from the same object. Please take a look at a screenshot: And this is my current piece of code: override func viewWillAppear(animated: Bool) { getFetchedResultController_cat(currentEntity_cat) } func getFetchedResultController_cat(selectedEntity: NSString){ let appDelegate : AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate let managedObjectContext:

Selecting first row in UIPickerView issue

两盒软妹~` 提交于 2019-12-06 10:43:24
I've a many textfield and a pickerView with toolBar and it has a done button . My issue is I can't select the first row from the picker. While I have debugged in the didSelectRow but it won't run inside it. So please where would be my issue? func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { var value = currentPickerArray[row] textFieldOutletArray[currentTag].text = value } Just replace didSelect method in your sample code like as bellowed. it will working fine. @IBAction func doneBtn(sender: AnyObject) { var row = pickerView.selectedRowInComponent(0