uipickerview

iphone uipickerview : image and text

ⅰ亾dé卋堺 提交于 2019-12-06 08:11:25
问题 is it possible to have an image (like an icon) next to a text in UIPickerView ? I saw examples of UIPickerViews with two Columns :one that has an image and another one with the text . this is not what I need , I need to have a single column with text and Images Thanks. 回答1: You will need to create your own view for each row of the picker. This is easy enough if it's just a UIImageView and a UILabel. You can then pass the view to your picker using this UIPickerViewDelegate method. - (UIView *

UIPickerView selectRow:inComponent:animated not working in viewDidLoad but working in viewDidAppear

半城伤御伤魂 提交于 2019-12-06 07:45:41
This issue is driving me crazy. I have a UIPickerView that I loaded in viewDidLoad, and I need to initialize the selected row that is to appear on the screen. My code is as follows: self.pickerSkins.delegate = self; [self.pickerSkins reloadAllComponents]; NSLog(@"%d", [self.pickerSkins numberOfRowsInComponent:0]); [self.pickerSkins selectRow:1 inComponent:0 animated:NO]; I have put this in viewDidLoad. NSLog logs a value of 2. However, the selected row that pops up is always the first row and not the second. If I put the selectRow in viewWillAppear, it also doesn't work. If I put the selectRow

make uipickerview appear between cells when touched cell

前提是你 提交于 2019-12-06 07:30:17
问题 I like to implement UI like this screen. as you see, when I touch a specific cell, pickerview appears at the bottom of that cell. and it sits between two cell. and pickerview doesn't seem to be a subview of cell. How do I implement this? I don't know where to start... 回答1: You can insert a new cell which contains a UIPickerView when user tap on a cell by using this method - - (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation Also for this

UIPickerView button selector issue in iOS 7

寵の児 提交于 2019-12-06 07:12:22
问题 Having a weird issue of UIPickerView only on iOS 7 I have a UIPickerView which contains 3 rows. Each row has a button whose selector is defined, but it never respond on button tap. Here is my code. - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { NSLog(@"row %d", row); if(view == nil) { view = [[[UIView alloc] init] autorelease]; } [view setFrame:CGRectMake(0, 0, 320, 44)]; UIButton *manageButton =

UIPickerView Width in iOS8 Swift

青春壹個敷衍的年華 提交于 2019-12-06 06:54:49
问题 I simply can not find out how to get a width of a component on my UIPickerView. It's not allowing something simple (Int) as it needs to be CGFloat. What exactly do I put in the <#code#> section? func pickerView(pickerView: UIPickerView, widthForComponent component: Int) -> CGFloat { <#code#> } Thank you! 回答1: That method doesn't "get a width of a component..." The picker view calls that method to ask you how wide a component should be. Your method could be as simple as: func pickerView

iphone uipickerview with images

跟風遠走 提交于 2019-12-06 06:38:02
问题 it's possible add as item in the uipickerview some images/icons instead of text? thanks 回答1: yes it is absolutely possible. u need to handle pickerView delegate method - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view here you simply return custom view(could be anything UIImage UILabel) and set userInteractionEnable property to no for customize view.. 来源: https://stackoverflow.com/questions/4366974/iphone

UIPickerView - Unable to tap item to select in ios7

我只是一个虾纸丫 提交于 2019-12-06 05:23:18
On iOS7 I have a UIPickerView with three components in my App (see image below). All three comonents can be rotated when swiped across. Fine! But normaly when user tapps BELOW or ABOVE the currently selected row, the picker wheel rotates the tapped value to the center. The middle (yellow) component bahaves as expected when tapped. But the left and right components behave strange: the do not react to the tap below or above. They can only be rotated when "swiped" - but not when clicked. See image below: If I tap on the yellow column on the value 22,23,24 or 26,27,28 these values rotate to the

UIPickerView selectrow crash in iOS 6

﹥>﹥吖頭↗ 提交于 2019-12-06 02:43:57
My application build & run in iOS 5.x perfectly, but it crashes when I call selectRow:inComponent:animated: method of UIPickerView in iOS 6. code : [_pickerview selectRow:1 inComponent:0 animated:NO]; I know this method is not work in iOS6 when I googled it, but I want to know other method to do this effect? Your crash log says you have used a -1 in code where should be a number in range {0, 1}. But in the the code you paste you indeed use 1 . So you need to check your parameter for your xxx and yyy [_pickerview selectRow:xxx inComponent:yyy animated:NO]; The above answers are correct, However

Manage a UIPickerView from an External Class - Using Swift

泄露秘密 提交于 2019-12-06 01:41:47
问题 I cannot seem to find the connection to have an external class manage a view in a ViewController. I'm new to iOS and have spent considerable looking for a solution. Simple Example: Subclass of UIPickerView I create a file that is a subclass of UIPickerView and have it conform to the PickerView delegate and datasource. class MyPickerView: UIPickerView, UIPickerViewDelegate, UIPickerViewDataSource { //In here I conform to all the required methods...no problems there } Main View Controller with

Programmatically Create and Show UIPickerView

老子叫甜甜 提交于 2019-12-06 01:04:19
问题 I am attempting to create a UIPickerView programmatically and display it as the firstResponder of a textfield, however, the picker view is not showing up. textField is connected to an object in the interface builder, but pickerView is being created programatically. class View: UIViewController { @IBOutlet var picker : UIPickerView = UIPickerView.alloc() @IBOutlet var textField : UITextField = nil override func viewDidLoad() { super.viewDidLoad() picker = UIPickerView() picker.delegate = self