uipickerview

iOS7 UIPickerView doesn't properly display custom views with images

寵の児 提交于 2019-11-29 15:10:40
问题 This issue started happening in iOS7 with the new UIPickerView controller. To use images in your UIPickerView controller you must use the delegate method to return an image: pickerView:viewForRow:forComponent:reusingView: The problem is that the screen subsequently exhibits all kinds of strange behavior - the image views disappear as you move your finger up and down the control. 回答1: This is a solution posted on a dev forum which works as of iOS 7.0.2: - (UIView *)pickerView:(UIPickerView *

UIPickerView selectRow doesn't works

老子叫甜甜 提交于 2019-11-29 10:20:42
I try to select a row in my PickerView but it doesn't works. It stays at the first row. Here is my code: @IBOutlet weak var pickerView: UIDatePicker! func numberOfComponentsInPickerView(pickerView: UIPickerView!) -> Int { return 1 } func pickerView(pickerView: UIPickerView!, numberOfRowsInComponent component: Int) -> Int { return 10 } func pickerView(pickerView: UIPickerView!, titleForRow row: Int, forComponent component: Int) -> String!{ return String(row + 1) } //In viewDidLoad pickerView.selectRow(6, inComponent: 0, animated: true) The pickerView is working well it shows 1 to 10 but the

UIPickerView with NSDictionary

孤街醉人 提交于 2019-11-29 09:02:59
问题 I am a .NET programmer and new to Objective C. I am trying to make a UIPickerView which acts like a .NET dropdownlist. User sees the list of text and selects one and the selected value (which is the ID) is used in code. I have been browsing for almost half a day trying to figure this out. I could add a regular PickerView with list of strings, picker view with mulitple components and picker view with dependent components none of which seems to answer my query. Please help. 回答1: You can use a

Load data from json using UIPickerView

这一生的挚爱 提交于 2019-11-29 08:24:19
My Current View Controller is like this import UIKit import Alamofire class ViewController: UIViewController , UIPickerViewDelegate, UIPickerViewDataSource{ @IBOutlet var venuePicker : UIPickerView? var result = [String:String]() var resultArray = [String]() override func viewDidLoad() { self.venuePicker?.delegate = self Alamofire.request(.POST, "http://example.com/xxx/xx/xx").responseJSON() { (request, response, jsonData, error) in var venues = JSON(jsonData!) let d = venues.dictionaryValue for (k, v) in venues { self.result[k] = v.arrayValue[0].stringValue } self.resultArray = self.result

UIPickerview customisation

二次信任 提交于 2019-11-29 07:50:44
I would like to do some customization of the UIPickerView. End Goal: have a picker view rotating a few icon sized images. firstly i would like to change the black/grey boarder surrounding the spindle to a transparent colour. i.e. [UIColor clearColor]; Then shrink the picker view down so it is relatively small, (probably around 40 x 40 pixels) Experimenting with this is IB did not make it seem easy. Finally change the view returned to the picker for each section. This i think is easy with pickerView:viewForRow:forComponent:reusingView: The rest, not sure if it is possible or if i am going to

UIPickerView, detect “rolling wheel” start and stop?

喜欢而已 提交于 2019-11-29 07:20:16
I just discovered that if I do the following: Click the button that animates a UIPickerView into my view Quickly start the wheel rolling towards, then past, the last item Dismiss the view with a button Then it has not yet selected the last item yet. I tried this by simply outputting to the console whenever the didSelectRow method was fired, and it fires when the wheel stabilizes on the last item. Can I detect that the wheel is still rolling, so that I can delay checking it for a selected value until it stabilizes? If it matters, I'm programming in MonoTouch, but I can read Objective-C code

Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency',

[亡魂溺海] 提交于 2019-11-29 06:03:06
I created a toolbar above the picker with two buttons and worked on ios7, when i run in ios8 crash: Terminating app two to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'child view controller: Should Have parent view controller: but requested parent is: ' This is the piece of code that worked quietly in ios7: expiredPromoTextField.inputView = DatePicker; expiredPromoTextField.delegate = self; quantityPromoTextField.inputView = quantityPicker; quantityPromoTextField.delegate = self; // Create button to close the UIPickerView UIToolbar * mypickerToolbar = [[UIToolbar alloc

Assertion failure in -[UIPickerTableView _createPreparedCellForGlobalRow:withIndexPath:], /SourceCache/UIKit_Sim/UIKit-2903.2/UITableView.m:7768

强颜欢笑 提交于 2019-11-29 05:37:33
I am trying to show UIPickerView with UIToolBar but getting some error. Here is my code - CGRect toolbarTargetFrame = CGRectMake(0, self.view.bounds.size.height-216-44, 320, 44); CGRect datePickerTargetFrame = CGRectMake(0, self.view.bounds.size.height-216, 320, 216); UIView *darkView = [[UIView alloc] initWithFrame:self.view.bounds]; darkView.alpha = 0; darkView.backgroundColor = [UIColor blackColor]; darkView.tag = 9; UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissDatePicker:)]; [darkView addGestureRecognizer:tapGesture];

Customize UIPickerView's Skin with images

百般思念 提交于 2019-11-29 04:30:55
I am developing an iPhone application. Where in, I want to have UIPickerView as in the image. Is it possible to change the appearance of UIPickerView like this?! Please guide me to do this!! I am creating it without XIB. Or is there a way to make UIPickerView skin transparent? Thanks in advance!! :-) I dont know this is a correct way or not but you can set your UIPickerView background image ... I have done it once. See this :- //Make a view to set as background of UIPickerView UIView * viewForPickerView = [[UIView alloc]initWithFrame:CGRectMake(0.0, 0.0, 320.0, 216.0)]; [viewForPickerView

How do I change the text color of UIPickerView with multiple components in Swift?

若如初见. 提交于 2019-11-29 03:49:45
Below code will change the font colour of the picker view of all 3 components. However, it crash when I try to spin the wheel. I think it has to do with the didSelectRow function. Maybe the two function have to be nested somehow? Any idea? func pickerView(pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? { var attributedString: NSAttributedString! if component == 0 { attributedString = NSAttributedString(string: a.text!, attributes: [NSForegroundColorAttributeName : UIColor.redColor()]) } if component == 1 { attributedString =