uipickerview

UIPickerView简单选择器的基本使用

你离开我真会死。 提交于 2020-03-19 04:14:15
//创建一个类,实现UIPickerView的基本功能 #import "PickerViewController.h" //  遵守 UIPickerViewDataSource,UIPickerViewDelegate协议 @interface PickerViewController ()<UIPickerViewDataSource,UIPickerViewDelegate> //  声明一个简单选择器 @property (nonatomic,strong) UIPickerView *picker; //  picker第一列数据的数据源数组 @property (nonatomic,strong) NSMutableArray *firstList; //  picker第二列数据的数据源数组 @property (nonatomic,strong) NSMutableArray *secondList; //  用于显示简单选择器上选择的内容 @property (nonatomic,strong) UILabel *showLable; //  picker选择完点击按钮用于更新lable上的数据 @property (nonatomic,strong) UIButton *button; //  picker第一列选择的数据 @property

IOS开发之UIPickerView

二次信任 提交于 2020-03-19 04:13:32
前言: UIPickerView 是一个选择器控件, 它可以生成单列的选择器,也可生成多列的选择器,而且开发者完全可以自定义选择项的外观,因此用法非常灵活。UIPickerView 直接继承了 UIView ,没有继承 UIControl ,因此,它不能像 UIControl 那样绑定事件处理方法, UIPickerView 的事件处理由其委托对象完成。 UIPickerView 控件常用的属性和方法如下: numberOfComponents: 获取UIPickerView指定列中包含的列表项的数量。该属性是一个只读属性。 showsSelectionIndicator: 该属性控制是否显示UIPickerView中的选中标记(以高亮背景作为选中标记)。 numberOfRowsInComponent: 获取UIPickerView包含的列数量。 rowSizeForComponent: 获取UIPickerView包含的指定列中列表项的大小。该方法返回一个CGSize对象。 selectRow:inComponent:animated:: 该方法设置选中该UIPickerView中指定列的特定列表项。最后一个参数控制是否使用动画。 selectedRowInComponent:: 该方法返回该UIPickerView指定列中被选中的列表项。 viewForRow

Swift 3 - SIGABRT error - numberOfComponentsInPickerView:]: unrecognised selector sent to instance

久未见 提交于 2020-03-03 09:23:27
问题 Just updated to Swift 3 and xCode 8 Beta 4. After fixing all the code issues I now have an error free project but it is throwing a SIGABRT error when clicking one particular button on my front screen. I am sure that it is something to do with the UIPickerView element on the destination page as I have deleted, checked and re added all segues and outlets to make sure everything is clear from that side. The console is showing the following: 2016-08-02 18:59:46.607 ForceIt![38735:2895259] -

iOS – Weird exception

流过昼夜 提交于 2020-02-03 01:47:13
问题 I'm getting a strange exception in Xcode 4.2.1 (ARC-enabled project) that I can't track down to the root of the problem. This is what the exception looks like: 2012-03-18 22:19:32.855 Project[14225:707] +[UIPickerTableViewTitledCell isEqualToString:]: unrecognized selector sent to class 0x3f2bbec4 2012-03-18 22:19:32.859 Project[14225:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[UIPickerTableViewTitledCell isEqualToString:]: unrecognized selector

Adding UIPickerView to UIActionSheet (buttons at the bottom)

孤街浪徒 提交于 2020-02-01 07:19:32
问题 I want to show a picker view (sliding up) deactivate the background while it's visible show (UIActionSheet) buttons at the bottom (not at the top) It seems to me an easy solution at first since you can find code for adding a picker view to an action sheet everywhere in the web but all solutions position the buttons at top and I need to put the buttons at the bottom of the action sheet (alignment?) . Is this possible? I guess it is if I look at: Example Regards Jeven EDITED (my solution based

Adding UIPickerView to UIActionSheet (buttons at the bottom)

折月煮酒 提交于 2020-02-01 07:19:26
问题 I want to show a picker view (sliding up) deactivate the background while it's visible show (UIActionSheet) buttons at the bottom (not at the top) It seems to me an easy solution at first since you can find code for adding a picker view to an action sheet everywhere in the web but all solutions position the buttons at top and I need to put the buttons at the bottom of the action sheet (alignment?) . Is this possible? I guess it is if I look at: Example Regards Jeven EDITED (my solution based

Multiple Picker Views on a single view

旧巷老猫 提交于 2020-01-26 02:55:06
问题 I have followed the following SO question to create multiple picker views. It works but not exactly how I want it. What I require: My view will have multiple buttons. On tap each button will show a picker view at the bottom of the screen.Each buttons picker view will have different options. See image below: What I have done: So far I have created two buttons and then added two picker views to my storyboard. See Below The code is below: import UIKit class ViewController: UIViewController,

How do I reuse a view inside UIPickerView in this case?

感情迁移 提交于 2020-01-25 10:14:38
问题 It seems that a lot of people just return a UILabel, but in my case I'm adding a label to a view. The view is never not nil. This is a different use of UIPickerView, because I'm rotating its components 90 degrees and having it scroll sideways instead of up and down. func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView { if view == nil { let customWidth = 300 let customHeight = 300 let view = UIView(frame: CGRect(x:0, y

Xcode: UIPickerView Change Individual Row Background Color

谁都会走 提交于 2020-01-24 15:45:06
问题 I have a UIPickerView with 3 components (or columns), and each column has a different amount of rows or items. I need to be able to set the background color for each row. I did some digging and found something that almost works, but not exactly what I need: - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { CGRect imageFrame = CGRectMake(0.0, 0.0, 15, 15); UIImageView *label = [[[UIImageView alloc]

UIPickerView foreground

巧了我就是萌 提交于 2020-01-17 13:45:26
问题 I have a problem with UIPickerView. I have 9 lists and I created a view with 9 buttons. For each button I have associated a flag: when I click a button, a picker appears with the list relating to selected tag. The problem is that when the picker appears, it's in the background and the buttons are seen above the picker. I have solved in this way: when the user clicks a button the others are set as hidden and the picker looks good. There is a better solution to have the picker in the foreground