Menu
  • HOME
  • TAGS

More than 1 UIPickerView Swift

ios,swift,uipickerview

You can use the same delegate methods to populate both UIPickerViews. Just populate them conditionally depending on which UIPickerView you're dealing with. For example, if your first UIPickerView's called firstPickerView and your second UIPickerView is populated by secondDataSet: var typesOfData = ["KB","MB","GB"] var secondDataSet = ["A","B","C"] func numberOfComponentsInPickerView(pickerView: UIPickerView) ->...

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

ios,swift,uipickerview

Pickers can have multiple wheels (components). For example, you might have separate wheels for each digit, or you might have day, month, and year wheels. They are numbered starting at 0. So "Component 0" is just the first wheel (and you only have one). Selecting rows is done by calling...

How to start scrolling UIPickerView before it's visible?

ios,objective-c,swift,uipickerview

You can try setting the alpha to the minimum non-zero value then set it to 1 when it starts scrolling (you can tell when it starts scrolling because it will call its delegate methods; viewForRow, titleForRow etc.) Not a perfect solution but might work for you.

Dynamic UIPickerView menu(s)

ios,swift,uipickerview

In the function textFieldDidBeginEditing, before calling picker.hidden = false, reload the pickerview.

Populating UIPickerView with Core Data objects using Swift

ios,swift,uipickerview

It seems like you are always retrieving the first element in the fetch result: Try change this: let indexPath = NSIndexPath(forRow: 0, inSection: 0) To this: let indexPath = NSIndexPath(forRow: row, inSection: 0) ...

ios swift: UIPickerView best practice?

ios,swift,uipickerview

It depends on controller appearance. If there only one choose action per screen it will be better to put Table View on it and selected row will be current selection. If screen has multiply fields, that user should act with, then, in my opinion, it's better to put label +...

Set Selected Second component in UIPickerView to a NSString [closed]

ios,objective-c,nsdictionary,uipickerview

You probably want: rowSelection2 = [secondComponent objectAtIndex:row]; since it is your secondComponent array that contains the current contents for the 2nd component of the picker view. This assumes that you populate the 2nd picker component with your secondComponent ivar. You have a few other issues. Change the method to this:...

How to distinguish between multiple uipickerviews on one page

swift,uipickerview

Here is the way you can do it: import UIKit class ViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate { @IBOutlet weak var dropdown_1: UIPickerView! @IBOutlet weak var dropdown_2: UIPickerView! var arraySizes5 = ["sverysmall", "ssmall", "snormal", "slarge", "sverylarge"] var arraySizes3 = ["ssmall", "snormal", "slarge"] override func viewDidLoad() { super.viewDidLoad() // Do any additional setup...

Use a UIPickerView in a Navigation Controller

ios,uipickerview

easiest probably is to add following to your infoGeneral viewDidLoad: method [_picker setDelegate:self]; best probably to set delegate in your storyboard via your picker view attributes inspector pane....

Objective-c PickerView displays memory locations instead of object variable names from singleton

objective-c,singleton,nsarray,uipickerview

Your arrayPickerRows stores a array of the weapons. When you set the title for the button, so when you use [arrayPickerRows objectAtIndex:selectedIndex], you will get the address of a weapon at index selectedIndex. In your code, you don't have the definition for the variable selectedRow. However, it should be of...

Update second UIPickerView based off previous picker selection

ios,objective-c,arrays,cocoa-touch,uipickerview

To start with, your controller should implement the UIPickerViewDataSource and UIPickerViewDelegate protocols, the first being the way to provide data for the picker. When you have that in place, all you have to do is call the second picker's updateAllComponents method to have it refresh its content. So a delegate...

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

arrays,swift,uitextfield,uipickerview

I managed to get was i was looking for with this: countryPicker.sort(){$0 < $1} It sorted the array from A-Z, and was the only way it worked for me....

How to use 2 UIPickerView's in one View Controller?

xcode,swift,uipickerview

Based on the information I have in the question, I'd say that you need to set up the data source & delegate methods to handle the ability to distinguish between which picker instance is calling them. Using the tag property on the picker view is one strategy. There should be...

'String' is not identical to 'Int8' - SWIFT

xcode,swift,uipickerview

If you want to show the ".00" part in the text, then you need to extract the whole number to do the arithmetic. Something like: var text = "" var whole: Int? = nil if let index = numbers[row].rangeOfString(".") { whole = numbers[row].substringToIndex(index.startIndex).toInt() } if whole != nil { text...

Use data from NSUserDefaults in UIPickerView - pickerView stays empty

ios,xcode,swift,uipickerview,nsuserdefaults

You are setting userDefaults with the key "exercisesList" but attempting to get the data back with a different key ("itemList")

Change colour of UIPickerView selection indicators

ios,iphone,xcode,ipad,uipickerview

The best solution I can offer is to place 2 UIImages on top of your picker wheel at the width of 1 and length set to your preference. This is how I overcame this. It does not work well if you require multiple size views so programatically doing it to...

Changing the size of my UIPickerView in Swift

ios,swift,uipickerview

You can't change the size of a UIPickerView without doing strange hacks. The class is written for specific dimensions and if you do hack it to change the size it leads to weird issues. I would suggest you use the iCarousel library to implement a custom picker view. ...

Selecting first row in UIPickerView issue

ios,swift,uipickerview

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); NSLog("value L %d", row) pickerView(pickerView, didSelectRow: row, inComponent:0) } Hope this help you....

UIPickerView centered columns

ios,timer,uipickerview

Try implementing the following delegate method: - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component Reduce the width to the minimum space you need and they should line up better since this prevents it moving the text to the left or right. Also try and center the text where it can go from 1 to...

Trouble with scope and arrays SWIFT

ios,xcode,swift,uipickerview,uipickerviewcontroller

You won't have access to row unless you store it as an instance variable. I think this is a case where it would be unnecessary, though. You're half-way there. You have already discovered how to retrieve the selected row index from your picker and you already know how to select...

Hidden Values in UIPickerView

ios,uiviewcontroller,xcode6,uipickerview

In UIPickerViewDelegate you can set the rows' titles with pickerView:titleForRow:forComponent: as described in the documentation. The UIPickerView's selectedRowInComponent: will return you the current selected row: use the previous data source with this index to retrieve the current selected title....

UIPickerView not displaying data or calling viewForRow

ios,objective-c,uipickerview

Fuji sir, My recommendation would be as follows based on our conversation: - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. [self printFromCoreData]; _ActiveDevice = [[NSString alloc]init]; // Connect data self.DevicePicker.dataSource = self; self.DevicePicker.delegate = self; } - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component...

xcode ios NSRangeException on creating subviews

ios8,uipickerview,uiactionsheet,subviews

I've tested it with iOS 8.0 (and running on XCode6.1) and above, and your code and UIActionSheet both looks nice. It can compile, run and showing me the output. Here's what I get. Update: From iOS 8.0 and above, UIActionSheet is depreciated. Also its stop supporting add subviews too. This...

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

swift,uipickerview,uicolor

Use CGFloat not Float Check the API docs when you get an error like this...

Cant update a UITableView data depending on the selector from UIPickerView

objective-c,uitableview,nsmutablearray,uipickerview

First of all the problem is you are reinitiating UITableView in ViewController.m file. You dont need to reinitiate tableview if you connect the outlet to the interface file. In -(void)getNoticiasArrayForSeccion there is no need to allocate the object. You can simply get an object in ivar directly without allocating it....

Reload Component in UI Picker View Swift

xcode,swift,uipickerview,uipickerviewcontroller

Here is a version that works. I created my own CarMakeModel class to test it. You were overthinking the titleForRow function which was your primary problem. Also, in didSelectRow you need to update the class property picker2Options and not a local variable. I changed other things. I'd recommend you compare...

Picker saves random data to NSUserDefaults

ios,objective-c,nsuserdefaults,uipickerview

You are setting your preferences on the Picker's datasource call for the row title, instead of the delegate call for when the row is selected. For every row that is loaded into the view, pickerView:titleForRow:forComponent: is called, at which point you set the class preference, however, this does not correspond...

NSAttributedString in Swift

swift,ios8,uipickerview

Rewrite the key line with self and all will be well: newView!.attributedText = self.pickerView( pickerView, attributedTitleForRow:row, forComponent:component) This will allow your code to compile. The reason is apparently that the pickerView in the method parameters is overshadowing your existing pickerView... method. Using self disambiguates. (However, I'm concerned that this is...

Multiple separate Pickerviews in Swift

ios,swift,uipickerview

For displaying two components you need to change your methods like: func numberOfComponentsInPickerView(pickerView: UIPickerView!) ->Int { return 2 } func pickerView(pickerView: UIPickerView!, numberOfRowsInComponent component: Int) ->Int { var rows = var2.count if component == 0 { rows = var1.count } return rows; } func pickerView(pickerView: UIPickerView!, titleForRow row: Int, forComponent...

How to hide keyboard when you select UIPickerView in Swift

ios,swift,datepicker,uitextfield,uipickerview

Discard the last answer. I understood whAT you are doing. Here is what I found: Placing the declaration of the UPickerView objects in the scope of the class rather than localized to the handler seemed to work. Here is the code. Note the addition of the resignFirstResponder(). import UIKit class...

How can I get images to appear in UI PickerView Component in Swift?

ios,swift,uipickerview

You will need to implement a couple more the delegate methods for the UIPickerViewDelegate protocol. In particular a rowHeight delegate method and a viewForRow delegate method. Something like: // MARK: UIPickerViewDataSource func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int { return 1 } func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { return...

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

ios,objective-c,for-loop,uipickerview

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component This method is supposed to return an NSString, but you’re returning an object from the timing array, which you just filled with NSNumber objects. __NSCFNumber is a private subclass of NSNumber. Something inside the picker view is assuming that the object that you returned...

When connecting multiple UIPickerView,having error at titleForRow

swift,uitableview,uipickerview

If you are going to use multiple picker view, you have to use tag property at Attributes Inspector.So,Let say we have two UIPickerView.At the attributes inspector,set each UIPickerView with tag #1 and another with #2.And make sure they all connected to delegate and datasource of same view controller. Then in...

UIPickerView get darker on screenshot

ios,screenshot,uipickerview

You could try to use a different method for screenshot. Apple introduced in iOS 7 some methods for fast view screenshot. UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, 0); [self.view drawViewHierarchyInRect:self.view.bounds afterScreenUpdates:YES]; UIImage *im = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); Here is an answer from Apple that provides more info on how the 2 methods works. While the...

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

ios,xcode,swift,uipickerview,nsuserdefaults

The reason that your pickerViews are empty is most likely because you have not wired them up to viewController1 as dataSource and delegate. You can do this in the storyboard or in code: override func viewDidLoad() { super.viewDidLoad() let pickers = [pickerView1,pickerView2,pickerView3] for i in 0...2 { let pickerView :...

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

cocoa,fonts,size,uipickerview,nsattributedstring

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 follow this step : - you can use method of viewForRow like this func pickerView(pickerView: UIPickerView, viewForRow row: Int, forComponent...

UIPickerView: select one element after the other finishes animation

ios,iphone,uipickerview

Implement the delegate method pickerView:didSelectRow:inComponent:. Call selectRow on the fist picker, then when didSelectRow is called with row 3 for the first picker, call selectRow on the second picker....

UIBarButtonItem not clickable in UIToolBar

ios,swift,uipickerview,uibarbuttonitem,uitoolbar

Can you try this codes. var textField = UITextField(frame: CGRectMake(20, 50, view.width - 40, 30)) textField.backgroundColor = UIColor.redColor() view.addSubview(textField) var pickerView = UIPickerView(frame: CGRectMake(0, 200, view.width, 300)) pickerView.backgroundColor = UIColor.whiteColor() pickerView.showsSelectionIndicator = true var toolBar = UIToolbar() toolBar.barStyle = UIBarStyle.Default toolBar.translucent = true toolBar.tintColor = UIColor(red: 76/255, green: 217/255, blue:...

UIPickerView UIImage and Segue

ios,objective-c,uiimage,uipickerview

You are trying to [self performSegueWithIdentifier:@"toCameraView" sender:self] during UIImagePickerController dismissing, other words: cannot animate second VC appearing during first VC disappearing. Try to move [self performSegueWithIdentifier:@"toCameraView" sender:self]; inside completionBlock: -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [self dismissViewControllerAnimated:YES completion:^{ _img = [info objectForKey:UIImagePickerControllerOriginalImage]; if...

Assign a label to the text of a UIDatePicker

ios,objective-c,uipickerview,uidatepicker

NSDateFormatter *formatter; formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"dd/MM/yyyy"]; yourLabel.text = [NSString stringWithFormat:@"%@",[formatter stringFromDate:[birthdayPicker date]]]; I think you trying to do something like this example [self.dateFormatter setDateFormat:@"EE/YYYY"]; // Sun/2015 or [self.dateFormatter setDateFormat:@"EE/YY"]; // Sun/15 and here u can set the current date and the start/end date for your picker [self.dayPicker...

How do I get a list of countries in Swift ios?

cocoa-touch,swift,nsarray,uipickerview,nslocale

You can get a list of countries using the NSLocale class's ISOCountryCodes() method which returns an array of [AnyObject] which you cast as [String]. From there, you get the country name by using NSLocale's displayNameForKey method. It looks like this: var countries: [String] = [] for code in NSLocale.ISOCountryCodes() as...

How to reload, and reset the number of rows in a UIPickerView - Swift

ios,arrays,swift,uipickerview

You need to reload the picker view inside the getObjectInBackgroundWithId block/closure, which is called asynchronously. I don't know if that completion block runs on a background queue or the main queue, but if it's the former, you'll have to also dispatch the reload back to the main queue.

How to store data from a picker view in a variable when a button is pressed?

swift,ios8,uipickerview

Alright, after trying different things I finally came up with a solution to my problem. It might not be what the more experienced developers do but it worked for me just like I wanted. Here is what I did: @IBAction func saveButtonPressed(sender: AnyObject) { var chosen = pickerView.selectedRowInComponent(0) var chosenString...

How do I add rows to UIPickerView from UIAlertController

iphone,uipickerview,uialertcontroller

Ok so I will try to explain this: You declare a NSMutbleArray, you can't expect to use a NSArray because is not mutable, and you need to modify the content. NSMutableArray *array; UIAlertController * view; @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; NSArray* friends = [NSArray arrayWithObjects: @"jim", @"joe", @"anne",...

How is my array count 0?

arrays,swift,nsarray,uipickerview,nsxmlparser

First you should use pickerData.append(string) since your assignment will always set the array to contain a single (the last) element. Then you probably need to call reloadComponent...

How can I evenly space two UIPickerView side by side using storyboard constraints?

ios,ios7,xcode5,uipickerview,xcode-storyboard

Try using the following constraints shown in Image bellow : ...

UIFIleSharing populating UIPickerView

arrays,uipickerview

I solved it guys, thanks for all the help.. Code is below, for anyone interested. Don't forget to define your arrays! NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString *documentsPath = [paths objectAtIndex:0]; NSFileManager *fileManager = [NSFileManager defaultManager]; NSArray *bundleDirectory = [fileManager contentsOfDirectoryAtPath:documentsPath error:nil]; NSPredicate *Option = [NSPredicate predicateWithFormat:@"self ENDSWITH '.opt'"]; _OptionArray...

swift multilpe pickerView

ios,swift,xcode6,uipickerview

var result = "" for var i = 0; i < wheelContents.count; i++ { let selectedRow = pickerView.selectedRowInComponent(i) //get selected row in component let value = wheelContents[i][selectedRow] //get displayed value in component result += value + " " } sparLabel.text = result ...

PickerView load up tableview data Swift

xcode,uitableview,swift,uipickerview

I'm assuming you have a tableView within the same view as your pickerView (if that's what you're doing you need to make an outlet for your table view and connect it to the delegate and data source). My answer is based off of this assumption. Basically, just put a conditional...

How can I populate a UIPickerView column with multiple arrays depending on what the row in first column is?

ios,uipickerview

I would use a dictionary here, add the arrays to the dictionary and make the key the value for your bus. So when you want an array for a particular bus then you would get it like this NSMutableDictionary busStops [busStops setObject:stopArray007 forKey:@"007"] [busStops setObject:stopArray002 forKey:@"002"] [busStops objectForKey:@"002"] //Will return...

iOS Multiple Picker Views “Parse issue: Expected Expression”

ios,uipickerview

The syntax problem is straight forward: those else's need conditions, like: if (pickerView.tag == kCATEGORYTYPEPICKERTAG) return [categoryTypes count]; else if (pickerView.tag == kSOMEOTHERTAG_THAT_MEANS_USE_LOCATION_TYPES) return [locationTypes count]; else if (// etc. An if can have a single else with no condition. The implication is that the else condition is the complement...

Get selected value from UIPickerView custom delegate & data source

ios,swift,delegates,uipickerview

The UIPickerView class has a method named: `selectedRowInComponent'. This function may help you select components in a picker view. Here is more information on the class to help you with your project. Also make sure your view controller conforms to the UIPickerViewController Delegate and Data source....

UIPickerView selectRow doesn't works

swift,uipickerview

While inside the viewDidLoad method, your picker is empty. Since there is no 6th element to pick, it doesn't pick it. You can do this if you delay execution of the select call until after the data is finished loading. Likely one cycle will be enough. First though, try moving...

Multiple UIPickerView in the same UIView

ios,swift,uipickerview

You don't need tags, just use: func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int{ if pickerView == pickerView1 { //pickerView1 } else if pickerView == pickerView2{ //pickerView2 } also don't forget to set delegate in IB or in code: pickerView1.delegate = self ...

Horizontal UIPickerview Swift

ios,iphone,swift,uipickerview

The code it would take to create a custom widget like that would probably be outside the scope of a StackOverflow answer, but you can use the cocoa pod AKPickerView.

Adding protocols for dynamically created UIPickerView

ios,objective-c,delegates,protocols,uipickerview

You are trying to set a class as delegate. Do set an instance to resolve this issue. UIPickerView *pv = [[UIPickerView alloc] initWithFrame:CGRectMake(x, y, width, height)]; pv.delegate = self; instead of UIPickerView *pv = [[UIPickerView alloc] initWithFrame:CGRectMake(x, y, width, height)]; Class<UIPickerViewDelegate, UIPickerViewDataSource> delegatedClass = (Class<UIPickerViewDelegate, UIPickerViewDataSource>)[self class]; pv.delegate = delegatedClass;...

Size UILabel in UIPickerView to fit

ios,objective-c,uilabel,uipickerview

See the docs for UILabel. You want to do the following: if (!tView) { tView = [[UILabel alloc] init]; [tView setFont:[UIFont systemFontOfSize:15]]; tView.adjustsFontSizeToFitWidth = YES; tView.minimumScaleFactor = 0.7; // adjust as needed } Do not set numberOfLines. That's only useful when you want the text to wrap to multiple lines....

How can I populate a picker view depending on the selection of another picker view in Swift?

ios,swift,uipickerview

As both the Pickers are using the same delegate you are going to need a way to identify them when your delegate methods run, also your current Array structure means you are going to need a way to select each item array as and when the country is selected. Create...

Getting NSDictionary key by index?

ios,objective-c,ios7,nsdictionary,uipickerview

Since NSDictionary is an unordered associative container, it has no concept of indexing. Its keys are ordered arbitrarily, and that order can change in the future. You can get an NSArray of keys from the dictionary, and apply indexing to it: NSArray *keys = [myDict allKeys]; // Warning: this order...

Swift for iOS: change array order and populate Picker

ios,arrays,swift,uipickerview

If I may make a suggestion: extension Array { func rotated(steps : Int) -> [T] { return [T]( self[steps..<self.count] + self[0..<steps] ) } } func indexOf<T: Equatable>(ary : [T], theItem : T) -> Int? { for (i, obj) in enumerate(ary) { if obj == theItem { return i } }...

UIPickerView is Selecting the Wrong Row-Swift

ios,swift,cocoa-touch,uipickerview

I think you need to remove the line activeQuizPlace = row from the code you have shown and then add this function below. func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { activeQuizPlace = row } The function you were using is not called with the index that the...

Using NSObject for a UIViewDelegate instead of a UIViewController

swift,uiviewcontroller,uipickerview,uipickerviewdelegate

dataSource and delegate are weak properties, you should declare timePickerViewDelegate as an instance property to hold a strong reference to the delegate. let timePickerViewDelegate = TimePickerViewDelegate() override func viewDidLoad() { super.viewDidLoad() timePickerView.dataSource = timePickerViewDelegate timePickerView.delegate = timePickerViewDelegate } ...

UIPickerView with “external” DataSource and Delegate in Swift

ios,swift,uipickerview,uipickerviewdatasource,uipickerviewdelegate

Both delegate and datasource are unowned references. This means that c1 and c2 will get released as soon as you go out of scope. Try declaring c1 and c2 as properties of the class. Unowned references do not create a strong hold on the referred object (a.k.a. they don't increase...

How to fill a pickerview with data and run an activity indicator at the same time?

ios,objective-c,uipickerview,performselector

When you use performSelector:, it executes on the same thread as though you had simply called the selector directly. - (void) viewDidLoad { [super viewDidLoad]; [ai startAnimation]; // ACTIVITY INDICATOR STARTS SPINNING. [self performSelector:@selector( get_data ) // FILL ARRAY. withObject:nil afterDelay:0]; } - (void) get_data { // CALL WEB SERVICE,...

How do I use one UIViewController and two UIPickerViews?

ios,swift,uipickerview

You can make an arbitrary object that conforms to the UIPickerViewDataSource and UIPickerViewDelegate (or just one or the other) and then set the delegate and/or dataSource to this object like so (for simplicity I created two classes, but one could easily create one class with a convenience init that takes...

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

ios,uipickerview,voiceover

If you are implementing the pickerView:viewForRow:forComponent:reusingView: method of UIPickerViewDelegate as the way to populate the UIPickerView components, you can achieve custom accessibility label for each row by setting accessibilityLabel on the UIView you are returning from that method. Note that I wasn't successful at making VoiceOver read custom accessibility label...

Inline UIPicker Implementation

ios,objective-c,uitableview,uipickerview,tableviewcell

In your showPicker function, you don't seem to do anything? You create a cell, do things with it then it dies when that function ends. The cell is not added anywhere from what I can see? You need to add the picker inside cellForRowAtIndexPath, for the index path you know...

Data not populating in UIPickerView when field is tapped

ios,swift,uipickerview

Your ViewController implements the UIPickerViewDelegate and UIPickerViewDataSource methods, but you need to set your ViewController as the delegate and datasource of your UIPickerView. Add this code to viewDidLoad: dataPickerView.delegate = self dataPickerView.dataSource = self and have your ViewController class declare that it conforms to the UIPickerDataSource protocol by changing class...

Choose which ViewController to switch to by Picker View

ios,objective-c,xcode6,uipickerview

Having a viewcontroller for every category is definitely not the way to go. You'll want to make a QuestionViewController which knows how to handle and display Question objects. You can fetch the correct questions based on your selection. As for what you were doing, this would work: Have a UIViewController...

UIPickerView reloading not working

ios,swift,uipickerview

You need to update component 1 when the user has selected a make from component 0. Implement pickerView:didSelectRow:inComponent: and then update your makeIndex there: func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { if component == 0 { makeIndex = row pickerView.reloadComponent(1) } } Here are the corresponding changes...

SWIFT - 'double' not convertible to 'string'

ios,xcode,swift,uipickerview

Issue is with the following function: func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String! { return numbers[row] } The return type of thee function in String but you are returning a Double. Change it like: func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String! {...

Using UIPicker to create desired number of rows in UITableViewController

ios,iphone,uitableview,uipickerview

As Nitin Gohel said: In your TableView.h @interface TableViewController : UITableViewController @property (nonatomic) NSInteger numberOfRows; @end And in your TableView.m - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.numberOfRows; } Don't forget to assign the value of number of rows when your start button is tapped....

How to get selected row's title and value in uipickerview?

ios,objective-c,sqlite,uipickerview

Try This.. May be help full.. Like this you can add both array as dictionary NSMutableArray *nameArray = [[NSMutableArray alloc]initWithObjects:@"Come",@"Say",@"Go", nil]; NSMutableArray *regionArray = [[NSMutableArray alloc]initWithObjects:@"Hi",@"Hello",@"Bye", nil]; NSMutableArray *mainArray = [[NSMutableArray alloc]init]; for (int index = 0; index<regionArray.count; index++) { NSMutableDictionary *dataAddDic = [[NSMutableDictionary alloc]init]; [dataAddDic setValue:[nameArray objectAtIndex:index] forKeyPath:@"name"]; [dataAddDic...

Change UIPickerView font size for different column

ios,iphone,uipickerview

To customize your picker's views, you have to use pickerView:viewForRow:. In order to do this, remove pickerView:titleForRow: entirely, and within pickerView:viewForRow:, set retval's text using the conditional you originally used within pickerView:titleForRow:. - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { UILabel *retval = (UILabel*)view; if (!retval) { retval =...

iOS Multiple UIPickerView Only Showing 1 view

ios,uipickerview

You can do something like this. This is just an example, you have to make changes to make it work for your app #import "ViewController.h" #import <MessageUI/MessageUI.h> #import <MessageUI/MFMailComposeViewController.h> #define GeoLocation TRUE // FALSE for no latitude/longitude information #define kPICKERCOLUMN 1 typedef NS_ENUM(NSInteger, PickerType) { CATEGORY_PICKER, LOCATION_PICKER, ORIGINATOR_PICKER, DESTINATION_PICKER, STATUS_PICKER...

Accessing a variable stored within a class Swift

class,swift,instance,uipickerview

sportResult its not a delegate or a data source of your picker view so its selectedSport property will never be initialized since its didSelectRow method will be never called. To get the selectedSport you have to get it from sportPickerData which is actually the delegate and data source of your...

Problems linking a button with my picker view answers

ios,uipickerview

If I understand what you want to do, then the following should be correct. You have a label you are setting to the value received from the picker. Then the user clicks a button and is taken to the corresponding screen in the app. You only have one button that...

add UiPickerView into AlertController

ios,swift,uialertview,uipickerview

In your createContainerView function assign yourself as the delegate as follows: self.currPicker.dataSource = self self.currPicker.delegate = self ...

Data picker populating correctly for one field but not the other

ios,swift,uipickerview

Include enterSport.inputView = dataPickerView to set the correct firstResponder....

Xcode UIPickerView “NSInvalidArgumentExpression”?

objective-c,xcode,xcode6,uipickerview

It looks like categoriesData is not assigning the value properly. Try to change this line below and check:- self.categoriesData = _dataArray; ...

Dynamically created UIBarButtonItem doesn't trigger on tap

ios,objective-c,uipickerview,uitoolbar

The problem is that the UIToolbar isn't entirely inside the frame of the UIPickerView. As your code is written, although UIToolbar is a subview of UIPickerView, the toolbar is -pickerToolbar.bounds.size.height above the UIPickerView: [pickerToolbar setFrame:CGRectMake(0, -pickerToolbar.bounds.size.height, 320, 44)]; so you're unable to interact with its buttons because it's hanging off...

Pass uipickerview row title to a function

ios,function,uipickerview

You can access your selected row by accessing the array: You can get it in the following manner: NSInteger row; row = [self.pickerView selectedRowInComponent:0]; getCurrent:_pickerData[row] ...

Take data from Enum to show on UIPickerView Swift

ios,swift,enums,uipickerview

As mentioned by ABakerSmith you can use the Printable protocol to display the String in the UIPickerView. In the end you can have a ViewController looking as the following: // // ViewController.swift // Test // // Created by Stefan Veis Pennerup on 04/05/15. // Copyright (c) 2015 Kumuluzz. All rights...

iOS UIPickerView: How to limit the scrolling range

ios,uipickerview

//viewDidLoad UILongPressGestureRecognizer* gestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(pickerLongPressDetected:)]; gestureRecognizer.minimumPressDuration = .001; gestureRecognizer.cancelsTouchesInView = NO; gestureRecognizer.delegate = self; [self.rollerView addGestureRecognizer:gestureRecognizer]; -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{ //...

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

ios,arrays,swift,uipickerview

Selecting Rows in the View Picker override func viewDidLoad() { super.viewDidLoad() pickerView.delegate = self pickerView.selectRow(0, inComponent: 0, animated: false) } ...

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

ios,swift,uipickerview

You can use additional variable to store the latest sender button which was used to open a picker and check its value in the pickerView:didSelectRow:

swift: not identical to ‘UIPickerView’

swift,uipickerview

I think you want to print the data from which index is selected from UIPickerView,But I think you are doing this wrong way. here is the couple of example for you: var states : [String]! func pickerView(pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusingView view: UIView!) -> UIView {...

Populate Array with One Core Data Attribute

ios,arrays,core-data,swift,uipickerview

I'm just typing this in here, so not sure if it even compiles: let moc = self.managedObjectContext() let fetchRequest = NSFetchRequest(entityName:"WeightLog") var titleNames: [String] = [] if let weightLogs = moc.executeFetchRequest(fetchRequest, error: nil) as? [WeightLog] { titleNames = weightLogs.map { $0.title } // get an array of the 'title' attributes...

Adding UIPickerView and UIDatePickerView - in a UITableViewController

ios,uitableview,uipickerview,uidatepicker

I think you should use UViewController and add UITableView, UIPickerView and UIDatePickerView

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

U want pickerLabel background in view(selected) to turn cyan instead in all four components. U can change the code in pickviewdidSelectRow : if redIndex + blueIndex + yellowIndex + greenIndex == 6 { myPicker.backgroundColor = UIColor.cyanColor() } else { myPicker.backgroundColor = UIColor.whiteColor() } to : if redIndex + blueIndex +...

method titleForRow for UIPicker is not being called

ios,objective-c,uipickerview

You have set the UIPickerViewDatasource twice rather than setting the UIPickerViewDelegate. Change to: self.schedulePicker.dataSource = self; self.schedulePicker.delegate = self; ...

Faster way to add object to NSMutableArray from URL

objective-c,ios8,nsmutablearray,uipickerview,nsmutabledictionary

As referenced in my comment above, NSLog will be a significant use of time given a big enough list. Removing it from your loop will speed things up considerably.

UIPickerView selection array Swift

xcode,swift,uipickerview

cameron has to be replaced with a dynamic lookup. You'll need a dictionary of brands, which you can then tie to the UI: [As I was writing this up I found the variable names awful; please avoid 0, 1, 2, insanity of numbering your variables, 3, 4, bleah] At class...

How can i navigate to another view controller dependent on a variable

swift,button,uipickerview,viewcontroller

In @IBAction func Find() you could have switch statement where you check which item from UIPickerView was selected, and based on that you can present desired view controller like this: let cafeViewController: CafeViewController = CafeViewController() self.presentViewController(cafeViewController, animated: true, completion: nil) But are you sure you need it's own view controller...

Search bar at the top of a UIPickerView in Swift

swift,uitextfield,uisearchbar,uipickerview

UIPickerView is really meant for a few options - if you need to present something that has a lot more options, I would suggest a table view with a search bar. Search Bar Tutorial is a good start.