uipickerview

Reload UIPickerView crash [duplicate]

旧巷老猫 提交于 2020-01-17 06:03:49
问题 This question already has an answer here : Reload data and components in UIPickerView (1 answer) Closed 4 years ago . I'm trying to reload UIPickerView , because, when I chose a first item, at the second the placement of the selector don't get back to the first, so I try this: NSNotificationCenter.defaultCenter().addObserver(self, selector: ("updatePicker"), name: UITextFieldTextDidBeginEditingNotification, object: nil) func updatePicker(){ self.pickerView.reloadAllComponents() } But I get an

PickerView shows only '?'

谁说胖子不能爱 提交于 2020-01-17 04:43:05
问题 This is my source code and what I have done is make picker view on storyBoard. Make IBOutlet in this controller by contorl+drag. It can be compiled however, only '?' appears in the picker view. Where is the problem? import UIKit class SelectViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate{ var songNames = ["test1","test2","test3"] @IBOutlet weak var songPicker: UIPickerView! override func viewDidLoad(){ songPicker.delegate = self songPicker.dataSource = self }

Obj-C, showing a UIPickerView in an UIActionSheet, but need to save to NSUserDefaults and refresh table contents, but where?

天涯浪子 提交于 2020-01-17 01:17:30
问题 I was using pickerView didSelectRow to save the selected value to NSUserDefaults and re populate my table view. However, at the point the action sheet / picker view is still visible and the user can select new values and didSelectRow will be called again. EDIT: To clarify I don't want to populate my table view at this point. I'm looking for an event when I can save the value and re-populate after the picker view is dismissed. What can I use ? Here's my code to show the action sheet / picker

index for UIPickerView like UITableView?

[亡魂溺海] 提交于 2020-01-16 12:18:07
问题 Is it possible to have an index for a UIPickerView like one can have an index for a UITableView on the right hand side of the UITableView? The reason I am asking is that if one has a large list of items in the UIPickerView, it can take quite a while to scroll to the end of the list. 回答1: You might want to consider using a UITableView, but that doesn't answer your original question. Anything is possible with a little imagination, and just because you can't do something effortlessly in Cocoa

[UILabel numberOfComponentsInPickerView:]: unrecognized selector sent to instance …]

浪子不回头ぞ 提交于 2020-01-16 05:18:06
问题 In my iOS app I have created a table view controller with custom cells where one of them contains a PickerView. Here's the class for that custom cell: import Foundation import UIKit class PickerCell: UITableViewCell { @IBOutlet weak var label : UILabel! @IBOutlet weak var pickerView : UIPickerView! func configurePickerCell(labelText:String, pickerDelegate:MyPickerViewController, enabled:Bool, defaultValueIndex:Int) { self.label.text = labelText var labelFrame:CGRect = self.label.frame

Uipickerview behind item working

落爺英雄遲暮 提交于 2020-01-16 04:33:07
问题 I have pickerview in my view controller. I am displaying it by adding into subview and then changing frame of subview. When my pickerview displayed I have one button behind it. When I click on those area after dispalying pickerview still that button action is called. How to set pickerview proper? 回答1: U subclass the PickerView like below will help u to fix this issue. // // WPCustomPickerView.h // test // // Created by VASANTH K on 08/01/14. // // #import <UIKit/UIKit.h> @interface

swift: not identical to ‘UIPickerView’

允我心安 提交于 2020-01-15 11:29:05
问题 I tried the following method which works in Obj-C, but I got error in swift: '(@lvalue UIPickerView!, titleForRow: Int, forComponent: Int) -> $T7' is not identical to ‘UIPickerView’ func pickerView(pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusingView view: UIView!) -> UIView { var pickerLabel = UILabel() pickerLabel.textColor = UIColor.whiteColor() pickerLabel.text = pickerView(pickerView, titleForRow: row, forComponent: component) return pickerLabel } here

How to initialize UiPickerView inside custom tableViewCell?

本小妞迷上赌 提交于 2020-01-15 09:01:50
问题 I am trying to create PickerView inside tableViewCell . I made my custom cell conform UIPickerViewDelegate and UIPickerViewDataSource protocols. I send data array to cell from the controller (I think this doesn't conform to MVC pattern, may be you also can suggest me how to fix that?). But when tableview calls dequeueReusableCellWithIdentifier the cell calls pickerView function. However, pickerView function uses pickerData which is not initialized yet. How do I fix that? Below is my code for

How to make a UIDatePicker appear at bottom of screen?

元气小坏坏 提交于 2020-01-13 04:12:11
问题 I currently use MonoTouch with MonoTouch.Dialog. When tapping on a date field it pushes the navigationcontroller so you go right a screen to see your UIDatePicker where you choose the date then go "back" to the main screen again. I'd really like to have this UI like other apps I've used that when you select a date field the UIDatePicker appears at the bottom of the current screen. I would like to learn how to do this and apply it to other input fields where I may want to use a custom picker

Dismissing UIPickerView with Done button on UIToolBar

大城市里の小女人 提交于 2020-01-09 10:29:12
问题 I am just trying out which is better with regards to dismissing a UIPickerView -- a button on the navigation bar or a "Done" button on a toolbar above the picker view. I have implemented both buttons, and I am trying to dismiss the picker view and resign first responder. How can I dismiss the UIPickerView with the "Done" Button on the toolbar? This is my code for the UIToolBar : UIToolbar* keyboardDoneButtonView = [[UIToolbar alloc] init]; keyboardDoneButtonView.barStyle = UIBarStyleBlack;