FAQ Database Discussion Community


swift multilpe pickerView

ios,swift,xcode6,uipickerview
I can't seem to get all of my three options to appear when I populate my picker view. It will only give me the last selected column result. import UIKit class ViewThree: UIViewController, UIPickerViewDelegate { @IBOutlet var sizePicker: UIPickerView! var wheelContents:[[String]] = [] var one = ["1", "2"] var two...

How do I use one UIViewController and two UIPickerViews?

ios,swift,uipickerview
There are some older posts on this but I couldn't get them to work (I tried using the tag method below). I want to use two UIPickerView in one UIViewController in Swift but I can't figure out how to delineate them: class ViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource { var footballWinner =...

add UiPickerView into AlertController

ios,swift,uialertview,uipickerview
I am trying to create an alert message with built in UIPickerView in swift. After pressing the button "test" Picker should appear in alert window: The problem is only with data source for UIPickerView. It is empty: The project is published in my GIT repo. Can somebody advice on how...

How to hide keyboard when you select UIPickerView in Swift

ios,swift,datepicker,uitextfield,uipickerview
I have a DatePicker where the user selects time and date fields, the keyboard shows up first and then I have to click the textfield again for the Picker to appear. What I want is for the DatePicker to show up on the first try. here is my code @IBOutlet...

Trouble with scope and arrays SWIFT

ios,xcode,swift,uipickerview,uipickerviewcontroller
Hi Im developing an app with Parse and when the user creates an account there's an UIPickerView with different strings the user has to choose from. Im trying to save their choice in a string. I've got it working with but that saves a number not a string. let myRank...

Problems linking a button with my picker view answers

ios,uipickerview
im using a basic picker view in my application, the answer of that picker view is reflected in a label, everything great from there; but I want to link one button to every answer in the picker view so that way when you choose something in the picker view yo...

Multiple UIPickerView in the same UIView

ios,swift,uipickerview
I'm a complete beginner on iOS dev and I want to create a little iOS application. On this application, 3 UIPickerViews are supposed to display different data. My problem is on the display. I'm used to dev on Android or Windows phone and I don't understand how to populate the...

UIBarButtonItem not clickable in UIToolBar

ios,swift,uipickerview,uibarbuttonitem,uitoolbar
I have a UIPickerView and I am adding a UIToolBar with 2 UIBarButtonItems to it. var toolBar = UIToolbar() toolBar.frame.origin.y = -40 toolBar.barStyle = UIBarStyle.Default toolBar.translucent = true toolBar.tintColor = UIColor(red: 76/255, green: 217/255, blue: 100/255, alpha: 1) toolBar.sizeToFit() var doneButton = UIBarButtonItem(title: "Done", style: UIBarButtonItemStyle.Bordered, target: self, action: "donePicker")...

Picker saves random data to NSUserDefaults

ios,objective-c,nsuserdefaults,uipickerview
I've been working on a new tips & tricks project for a game called Dofus. In the first view the user is asked to pick their class out of a picker. Then they go to a next view and pick their level and stuff like that. The problem with the...

Inline UIPicker Implementation

ios,objective-c,uitableview,uipickerview,tableviewcell
I'm attempting to implement an inline UIPicker inside a table-view cell, similar to both this and this SO question. I believe I'm close in my implementation, but at the moment, no picker is displayed when I select the appropriate cell. Can anyone point me in the right direction in regards...

How is my array count 0?

arrays,swift,nsarray,uipickerview,nsxmlparser
I have a UIPickerView. I have a blank array set up until my code parses an XML request. So when it does I want it to populate the array with that data. Below is how I have everything set up. var pickerData = [] func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int)...

Data picker populating correctly for one field but not the other

ios,swift,uipickerview
I have a test project I am using to develop my code before I implement it in my real project. In the test, I have two fields that when tapped should bring up a dataPicker populated with the array for that field. This works fine for the first field (enterSeason)...

Adding UIPickerView and UIDatePickerView - in a UITableViewController

ios,uitableview,uipickerview,uidatepicker
I have a UITableViewController where I want to display a date picker when a row is selected and a pickerview when another row is selected (I plan to hide the other when one is displayed). I am having trouble adding the datepicker and picker view in the story board. I...

Swift for iOS: change array order and populate Picker

ios,arrays,swift,uipickerview
I am trying to write an photography app in Swift for iOS that establishes equivalent exposure settings for a specified ƒ-stop and shutter speed. There are several downstream parts to writing this app that I have not reached yet (thus you won't see the code for obvious components, like user...

How do I add rows to UIPickerView from UIAlertController

iphone,uipickerview,uialertcontroller
I have a UIPickerView that gets its data from an array that is defined in friends = [NSArray arrayWithObjects: @"jim", @"joe", @"anne", nil]; I have a button under the picker that is supposed to add new friends to the picker. When the button is pressed a UIAlertController pops up and...

Add numbers 0 - 59 to a NSMutableArray to display in a pickerView

ios,objective-c,for-loop,uipickerview
I have a UIPickerView. What I want to do is display numbers 0 - 59. I tried the following code: - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { return 60; } - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { NSMutableArray *timing = [[NSMutableArray alloc] init]; for (int i = 0; i < 60; i++)...

Accessing a variable stored within a class Swift

class,swift,instance,uipickerview
I can't figure out why I can't access this variable, see below, I want the value of sport result when it's clicked, however sportResult.selectedSport returns nil? let sportPickerData = SportPickerData() override func viewDidLoad() { super.viewDidLoad() sportPickerView.delegate = sportPickerData sportPickerView.dataSource = sportPickerData class SportPickerData: NSObject, UIPickerViewDataSource, UIPickerViewDelegate { var sports =...

Hidden Values in UIPickerView

ios,uiviewcontroller,xcode6,uipickerview
As beginner in iOS Developing I struggle with specific implementation ofUIPickerView. I already know how to createUIPickerView with specific data. My goal is a bit complicated though - I would like this PickerView to print me selected value. For example - like in simple currency calculator - I pick EUR...

Changing the size of my UIPickerView in Swift

ios,swift,uipickerview
I have a UIPickerView that I would like to change the size of frame. It seems that no matter how small I want it there is set minimum size that I can't go smaller than. I have seen other posts about this but they are very old and the code...

UIPickerView won't display the data loaded from NSUserDefaults - App is crashing while loading data

ios,xcode,swift,uipickerview,nsuserdefaults
I made a first try to use NSUserDefaults in an App with UIPickerViews. But the App is crashing while testing / the data isn't displayed in the PickerView. I still try to fix it myself but some help would be great. ViewController3: Where the user should save data to the...

Dynamic UIPickerView menu(s)

ios,swift,uipickerview
I'm trying to create an app that uses 2 text fields and 1 picker view. The picker should pop up once the user clicks in the first text-field. After the user makes a selection from the menu and clicks in the second text field, the picker pops up again but...

Horizontal UIPickerview Swift

ios,iphone,swift,uipickerview
I would like to make a Horizontal UIPickerview for iOS in swift I haven't found a solution for this issue. Do you have any idea ? Thank you !...

What is the meaning of “component” in a UIPickerView.selectedRowInComponent?

ios,swift,uipickerview
Using Swift in Xcode, I want to make: 1) A PICKER, with data from an array 2) A BUTTON, when pressed will update a LABEL with the text from a selected row of the PICKER My code currently: var array = ["Sydney", "London", "Washington", "Tokyo", "San Francisco"] func numberOfComponentsInPickerView(pickerView: UIPickerView)...

How to Force PickerView to default to array item [0]

ios,arrays,swift,uipickerview
I have been searching SO for two days now trying to find an answer to this. I may not even be asking the question correctly so forgive me if that is so. I want my data picker to default to the [0]th item of the data source array for that...

Populating UIPickerView with Core Data objects using Swift

ios,swift,uipickerview
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...

Using UIPicker to create desired number of rows in UITableViewController

ios,iphone,uitableview,uipickerview
I have a view with my UIPicker that will push to my UITableViewController when my start button is pressed. I want to create a certain number of rows per section in my UITableViewController from my UIPicker. Here is the relevant code. I'm not getting errors. My UITableViewController just doesn't have...

ios swift: UIPickerView best practice?

ios,swift,uipickerview
SOLVED! Code is updated and works!! Many thanks to Alex Zimin!! One short question: on a registration process I would like to ask the user to choose a value from a list of values. Is it the right way to use a view Controller adding there all text fields and...

UIPickerView is Selecting the Wrong Row-Swift

ios,swift,cocoa-touch,uipickerview
So I have UIPickerView that isn't working the way I want it to. It works correctly about 3/4 of the time, but the other 1/4 it doesn't. func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int { return 1 } func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { return listsArray.count } func pickerView(pickerView:...

Data not populating in UIPickerView when field is tapped

ios,swift,uipickerview
I am trying to learn how populate data into a UIPickerView programmatically instead of having the picker as an element on the main storyboard. I am practicing in a project so that when I get this done I can copy the code into the project I am actually trying to...

How do I change the background color of the text in view of the UIPickerView with multiple components when a valid selection is made, in Swift

ios,xcode,swift,uipickerview
Below code will change the background color of the UIPickerView to cyan showing it is a valid selection when total of row indexes = 6. Would like to have pickerLabel background in view(selected) to turn cyan instead in all four components when selection is valid. Any idea? import UIKit class...

How to set the Voice Over accessibility label for UIPickerView rows?

ios,uipickerview,voiceover
I'm trying to make a UIPickerView of mine Voice Over accessible, I've noticed that the UIPickerViewAccessibilityDelegate protocol is rather incomplete. It only allows you to specify labels and hints for pickerView components, not the rows within the components. (it also has a bug that its pickerView:accessibilityLabelForComponent: method doesn't pass a...

Send button, which opens UIPickerView to UIPickerView's selectRow function

ios,swift,uipickerview
I have two buttons, which opens one UIPickerView @IBOutlet weak var convertFromButton: UIButton! @IBOutlet weak var convertToButton: UIButton! I need picker's selectRow function to know, which button user press to open it and to change title of this button. So, I need function like this, but I don't know how...

UIPickerView get darker on screenshot

ios,screenshot,uipickerview
I had to alter the navigation on certain circumstances, and due to complexity of the transitions I had take an paint and screenshot until the transition is finished. In almost cases, that works pretty well, but there is a point that disturb me. I have a view controller with two...

Adding protocols for dynamically created UIPickerView

ios,objective-c,delegates,protocols,uipickerview
This question relates to this SO question (please see accepted answer). I'm adding a UIPickerView to a view which has not added the UIPickerViewDelegate or UIPickerViewDataSource protocols in its interface. However, all the required methods for the UIPickerView object has been properly implemented, and the program runs fine with these...

Take data from Enum to show on UIPickerView Swift

ios,swift,enums,uipickerview
I am creating a simple View where there is a UIPickerView and I want to display the choices on the PickerView from an enum. I have created an enum of possible drinks enum drink{ case coffee case tea case cola case water } I was wondering how it would be...

UIPickerView centered columns

ios,timer,uipickerview
I am creating a custom time picker, using this question as a guide and my columns don't line up. Here is where I create the hour and minutes labels: UILabel *hourLabel = [[UILabel alloc] initWithFrame:CGRectMake(datePickerCell.pickerView.frame.size.width/2 - 25, datePickerCell.pickerView.frame.size.height / 2 - 15, 50, 30)]; hourLabel.text = @"hour"; [datePickerCell.pickerView addSubview:hourLabel]; UILabel...

How to start scrolling UIPickerView before it's visible?

ios,objective-c,swift,uipickerview
I want to start dragging and make it visible at the same time. As of now, I have to click a button to make the pickerview visible and then scroll to select the desired row. How can I start the selection as soon as I start dragging from the button?...

UIColor initializer (cannot find an initializer of type 'UIColor' that accepts …) error [duplicate]

swift,uipickerview,uicolor
This question already has an answer here: Swift UIColor initializer - compiler error only when targeting iPhone5s 2 answers I know it is not an appropriate way to do this but for the purpose of learning I have a picker control with four components and 255 rows in each...

Reload Component in UI Picker View Swift

xcode,swift,uipickerview,uipickerviewcontroller
I am unable to reload the second component in my uPickerView that is based on the first component. I tried using the reloadAllComponents but it either does not work or crashes. What I am trying to work on is place car makes on the left and models of their cars...

Assign a label to the text of a UIDatePicker

ios,objective-c,uipickerview,uidatepicker
I have a UIDatePicker in which I'm trying to make it scroll horizontally instead of vertically. I found this tutorial which shows how to do it with a UIPickerView but not a UIDatePicker. The only problem I have is with the following line: label.text = [pickerViewArray objectAtIndex:row]; What would I...

Search bar at the top of a UIPickerView in Swift

swift,uitextfield,uisearchbar,uipickerview
So I have a textField, which when the user presses, it shows a UIPickerView, which is populated from an array. Is it possible for there to be search bar at the top of the pickerView, so the user can search for something in the pickerView? I've not seen this done...

method titleForRow for UIPicker is not being called

ios,objective-c,uipickerview
i want to use a UIPickerView in my project, but my titleForRow method is not being called even though numberOfComponentsInPickerView and numberOfRowsInComponent are called. Does anyone knows what to do with it? - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return 1; } - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { return pickerData.count; } - (NSString *)pickerView:(UIPickerView...

PickerView load up tableview data Swift

xcode,uitableview,swift,uipickerview
Currently, my uipicker has 3 selections, Cameron, Shaffer and Hydril. When I pick Cameron, i want my uitableview to load up camerondata1. If i pick Shaffer, I want it to load up camerondata2. How do I setup my UItableview to readjust according to the selection made on my picker view?...

Update second UIPickerView based off previous picker selection

ios,objective-c,arrays,cocoa-touch,uipickerview
At the moment, I have a list of name values in an array. I am populating the first picker with the names using the array but I want to load specific values into the second picker based off what I chose in my first picker. I am using a MySQL...

How to put an array in alphabetical order for UIPickerView in Swift

arrays,swift,uitextfield,uipickerview
So I have an array made of strings, and when the user presses on my textfield, it shows a PickerView using the array. I would like the PickerView to show the contents of the array in alphabetical order. But I have no idea how to do this, and cannot find...

Pass uipickerview row title to a function

ios,function,uipickerview
so i created a weather app. It has a text field where user types the city and then click the button. The city name will be passed to a function that will request a data for this city. I have passed the city name to this function -(void)getCurrent:(NSString *)query by...

UIPickerView reloading not working

ios,swift,uipickerview
I have a picker view with two components and five rows in each component. In the first component I have five makes of cars: Toyota, Ford, Honda etc... In the second component I have five models of the associated makes. When you change the make the models should update with...

UIPickerView selection array Swift

xcode,swift,uipickerview
Currently, I got my code to work correctly, but the problem I'm having issue with the UIPickerView. Right now, If I select Cameron brand, it goes to var Cameron but if i select Shaffer brand, it still goes to var Cameron. How can I rewrite the code so when I...

Use data from NSUserDefaults in UIPickerView - pickerView stays empty

ios,xcode,swift,uipickerview,nsuserdefaults
I tried to set up NSUserDefaults last night but an error keeps occurring: ViewController3: save data @IBAction func tappedAddButton(sender: AnyObject) { var userDefaults:NSUserDefaults = NSUserDefaults.standardUserDefaults() var exercisesList:NSMutableArray? = userDefaults.objectForKey("exercisesList") as? NSMutableArray var dataSet:NSMutableDictionary = NSMutableDictionary() dataSet.setObject(textField.text, forKey: "exercises") if ((exercisesList) != nil){ var newMutableList:NSMutableArray = NSMutableArray(); for dict:AnyObject in...