uipickerview

Objective C implementing a UIPickerView with a “Done” button

雨燕双飞 提交于 2019-11-26 16:28:55
问题 I am trying to implement a "Done" button in a UIPickerView Similar to the one under this link I looked in the class reference but I couldn t find it Thanks 回答1: I added a UIToolbar with a UIBarButtonItem for the 'done' button in my xib with the frame set so that it's not initially visible (y value equal to the height of the parent view). Every time the user access the picker, I changed the frame (the y value) of the UIDatePicker and the UIToolbar with an animation so that it slides up along

UIDatePicker select Month and Year

微笑、不失礼 提交于 2019-11-26 16:08:14
I need a UIDatePicker for selecting Month and Year only. I checked the class reference documents. Looks like UIDatePicker is a UIView . I imagined UIPickerView may be a sub view and I can hide the component if I can grab it. But no. That was not possible. Do I have to create my own custom picker then? Any ideas? Yeah, you probably want to just make your own picker. You don't have to subclass it or anything, though; just use a generic UIPickerView and return appropriate values from your UIPickerViewDelegate / UIPickerViewDataSource methods. Igor Here is a solution to get the same effect. For

Show UIPickerView text field is selected, then hide after selected

。_饼干妹妹 提交于 2019-11-26 15:49:05
问题 I am trying to create a text box that when it is selected a UIPickerView opens up with choices to select from. Once selected, the UIPickerView hides and the selected item is displayed in the text box. I tried different pieces of code I found online but I just can't get it to work. If someone can suggest a complete code for this or tell me what I am doing wrong in my code, that would be super awesome. Thanks so much. Here is my code: @IBOutlet var textfieldBizCat: UITextField! @IBOutlet var

UIPicker detect tap on currently selected row

∥☆過路亽.° 提交于 2019-11-26 14:03:57
问题 I have a UIPickerView and The method didSelectRow is not called when tapping on a selected row . I need to handle this case. Any ideas? 回答1: First, conform the class to the UIGestureRecognizerDelegate protocol Then, in the view setup: UITapGestureRecognizer *tapToSelect = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tappedToSelectRow:)]; tapToSelect.delegate = self; [self.pickerView addGestureRecognizer:tapToSelect]; And elsewhere: #pragma mark - Actions - (IBAction

display done button on UIPickerview

删除回忆录丶 提交于 2019-11-26 12:56:40
问题 I have written the following code in the viewDidLoad method: categoryPickerView=[[UIPickerView alloc]init]; categoryPickerView.alpha = 0; [self.view addSubview:categoryPickerView]; categoryPickerView.delegate=self; categoryPickerView.tag=1; and called this method to hide picker view - (IBAction)hidePickerView:(id)sender { [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.6]; CGAffineTransform transfrom = CGAffineTransformMakeTranslation(0, 200); categoryPickerView

How to steal touches from UIScrollView?

爱⌒轻易说出口 提交于 2019-11-26 12:10:40
问题 Today on my creative time I did some quite comprehensive research on how to steal touches from a UIScrollView and send them instantly to a specific subview, while maintaining the default behavior for the rest of the scroll view. Consider having a UIPickerView inside of a UITableView. The default behavior is that if you drag your finger over the picker view, the scroll view will scroll and the picker view will remain unchanged. The first thing I tried was to override - (BOOL

Add UIPickerView in UIActionSheet from IOS 8 not working

徘徊边缘 提交于 2019-11-26 12:03:38
问题 I am adding UIPickerView to UIActionsheet but its working perfectally in ios 7 but not working in ios 8 . Please help me to solve that. Here i attached screenshot for that. Thanks I am using following code for that. UIActionSheet *actionSheet; NSString *pickerType; - (void)createActionSheet { if (actionSheet == nil) { // setup actionsheet to contain the UIPicker actionSheet = [[UIActionSheet alloc] initWithTitle:@\"Please select\" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil

How do I change the color of the text in a UIPickerView under iOS 7?

允我心安 提交于 2019-11-26 11:56:23
问题 I\'m aware of the pickerView:viewForRow:forComponent:reusingView method, but when using the view it passes in reusingView: how do I change it to use a different text color? If I use view.backgroundColor = [UIColor whiteColor]; none of the views show up anymore. 回答1: There is a function in the delegate method that is more elegant: Objective-C: - (NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component { NSString *title =

Xcode 8 / Swift 3 : Simple UIPicker code not working

巧了我就是萌 提交于 2019-11-26 11:30:38
问题 I have protocols: class ViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource { I have data: let muteForPickerData = [\"minute(s)\",\"hour(s)\"] In viewDidLoad I have: muteForPicker.delegate = self muteForPicker.dataSource = self Then I have required methods: func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int { return 1 } func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { return muteForPickerData.count } func

UIPickView的显示与消失方法

a 夏天 提交于 2019-11-26 10:14:37
//PickerView appear -(void)ShowPickerView:(UIPickerView*)PickerViewTag { if(PickerViewTag.superview==nil) { [self.view.window addSubview:PickerViewTag]; CGRect screenRect=[[UIScreen mainScreen]applicationFrame]; CGSize pickSize=[PickerViewTag sizeThatFits:CGSizeZero]; CGRect startRect=CGRectMake(0.0, screenRect.origin.y+screenRect.size.height, pickSize.width, pickSize.height); PickerViewTag.frame=startRect; CGRect pickRect=CGRectMake(0.0, screenRect.origin.y+screenRect.origin.y+screenRect.size.height-pickSize.height, pickSize.width,pickSize.height); [UIView beginAnimations:nil context:NULL];