uipickerview

How do I change the font size in a UIPickerView in Swift 3?

拥有回忆 提交于 2019-11-30 01:16:41
问题 How do I change the font size in a picker view? I have read a lot of questions about this, but none are in Swift 3. I have three picker views; the first two have two columns and have the same data source and delegate. The last one has one column and has a different data source and delegate. I can't fit the text in the first two picker views by one character. How do I shrink the font size in a UIPickerView and adjust the picker view row height, if necessary? Thanks. class ViewController:

How do I reload/refresh the UIPickerView (with new data array) based on button press?

大兔子大兔子 提交于 2019-11-30 01:09:36
IF I wanted a picker, for states/provinces, i haven't seen an example, but I mocked up shown above, a picker for US/Can/Mex. wondering can you dynamically switch the NSMutableArray for the UIPickerView and then have it somehow reload each time you click on US/Can/Mex buttons??? How do I go about doing this. What approach do I take. Looking for someone to point a beginner for a clue in the right direction. You will have to implement the datasource and the delegate. once you press a button, set an array pointer to the appropriate array. than call [thePicker reloadAllComponents]; -(IBAction)

UIPickerview循环滚动

折月煮酒 提交于 2019-11-30 00:19:00
- ( NSInteger )numberOfComponentsInPickerView:( UIPickerView *)pickerView { return 1 ; } - ( NSInteger )pickerView:( UIPickerView *)pickerView numberOfRowsInComponent:( NSInteger )component { return self . group . count * 100 ; } - ( NSString *)pickerView:( UIPickerView *)pickerView titleForRow:( NSInteger )row forComponent:( NSInteger )component { return self . group [row % self . groupNames . count ]; } - ( CGFloat )pickerView:( UIPickerView *)pickerView rowHeightForComponent:( NSInteger )component { return 50 ; } 来源: oschina 链接: https://my.oschina.net/u/2418942/blog/528175

iOS开发11:UIPickerView控件(1)

你说的曾经没有我的故事 提交于 2019-11-30 00:18:11
UIPickerView控件是比UIDatePicker控件更普通的Picker控件,UIDatePicker控件可以理解成是从UIPickerView控件加工出来的专门进行日期选择的控件。 UIPickerView控件的用法比UIDatePicker复杂一点。本文中的小例子将用UIPickerView控件做出两种效果,第一个只有一个转盘,第二个有两个转盘,但这两个转盘之间没有依赖关系,也就是说改变其中一个转盘中的选择,不会对第二个转盘产生影响。在下一篇文章会做一个转盘之间有依赖关系的例子。 下图是我们的效果图: 第一个UIPickerView控件可以用来选择Horse,Sheep,Pig,Dog,Cat,Chicken,Duck,Goose;第二个UIPickerView在第一个基础上增加了一个转盘。 闲话少说,接下来就开始。 1、运行Xcode 4.2,新建一个Single View Application,名称为UIPickerView Test1,其他设置如下图: 2、单击ViewController.xib,然后拖一个Picker View控件到视图上: 然后再拖一个Button到Picker View下方,并修改名称为Select: 3、在ViewController.h中为Picker View控件创建Outlet映射,名称为myPickerView

Dependent UIPickerView

戏子无情 提交于 2019-11-29 22:12:09
问题 Does any one know how to make dependent UIPickerView. For example when i select row 2 of component one the titles for component two change? I have looked on the internet there is no real answer, i have tried using if and switch statements but they just crash. 回答1: It depends on how you are going to keep data. For an example if you have an array as the value of a key of a dictionary, and that dictionary have different such keys, the first column will be the keys, and on selecting one you will

How to set a default Value of a UIPickerView

断了今生、忘了曾经 提交于 2019-11-29 20:50:21
I have a problem with my UIPickerView. I have 3 values in it EU AP and NA. When I start the app EU seems to be selected but when I make a NSLog(@"%@", [regions objectAtIndex:row]); I only get back (null) , now when I touch the UIPickerView the EU value is selected and I get "EU" back from a NSLog. My question is: How can I define a default value which is selected (not only the label) when the user only starts the app and touches nothing. Edit: Here is my code to get the selected item: #pragma mark - #pragma mark PickerView DataSource - (NSInteger)numberOfComponentsInPickerView: (UIPickerView *

iOS Show UIPickerView between UITableViewCells

旧巷老猫 提交于 2019-11-29 20:42:04
In iOS 7, developers are encouraged to show date pickers between table cells when needed for input, and then hide them when done. How can I achieve this effect? Anthony F Vasilica Costescu has a great tutorial on it here: http://masteringios.com/blog/2013/10/31/ios-7-in-line-uidatepicker/ And for static tables: http://masteringios.com/blog/2013/11/18/ios-7-in-line-uidatepicker-part-2/ Sample code here: https://github.com/costescv/InlineDatePicker The key bits are the hide/show methods: - (void)showDatePickerCell { self.datePickerIsShowing = YES; [self.tableView beginUpdates]; [self.tableView

Add image to UITextField in Xcode?

[亡魂溺海] 提交于 2019-11-29 20:07:45
I need to implement the concept of dropdown in Xcode. For that purpose, I'm using a UIPickerview . This pickerView loads when a textfield is tapped (on textFieldDidBeginEditing:)event. Question: Is there a way, that I can add a image to TextField ? The image is like an arrow mark by which user can understand that a dropdown appears when textfield is tapped .How can I make it? Mayur Birari UITextField has a rightView property, if you have image like this- then You can easly set ImageView object to rightView: UITextField *myTextField = [[UITextField alloc] init]; myTextField.rightViewMode =

How to make an UIPickerView with a Done button?

ぐ巨炮叔叔 提交于 2019-11-29 18:59:28
I am having difficulties to make an UIPickerView with a done button to appear when the users taps a UITextField. This is my code so far. Everything builds fine, but when I tap the text field, the keyboard appears, not the picker. class ViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate { @IBOutlet var textField1: UITextField! let pickerData = ["11", "12", "13"] @IBAction func textButton(sender: AnyObject) { let picker: UIPickerView picker = UIPickerView(frame: CGRectMake(0, 200, view.frame.width, 300)) picker.backgroundColor = .whiteColor() picker

Multiple UIPickerViews

偶尔善良 提交于 2019-11-29 15:55:26
I have a dilemma, I have two UIPickerViews which "show" when two distinct views load. I started with one UIPickerView and was able to get that up and running by loading the array and all the other UIPickerView actions within the ViewController. I thought it would be as simple as copy/pasting the same methods for the new UIPickerView , but just changing the variable names, also within the same UIViewController . Problem is - both UIPickerView are showing the same data set in the drop down ? Am I simply missing something obvious here? Updated below I did that for all four methods below and now