隐藏/显示UIPickerView [英] Hiding/ Showing UIPickerView
本文介绍了隐藏/显示UIPickerView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个touchesEnded事件,用于检查何时按下UITextField.我想要做的是隐藏/显示UIPickerView.该怎么办?
I Have an a touchesEnded event that checks for when a UITextField is pressed. What I would like it to do is is hide/show a UIPickerView. How can this be done?
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [[event allTouches] anyObject];
if (CGRectContainsPoint([self.textField frame], [touch locationInView:self.view]))
{
NSString * error = @"Touched the TextField";
UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Selection!" message:error delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlert show];
//Want to show or hide UIPickerView
}
}
发生触摸时,我已经分配了UIPickerView
I already have an allocated UIPickerView when touches occur
@interface ThirdViewController : UIViewController <UITextFieldDelegate,UIPickerViewDelegate> {
IBOutlet UIPickerView *pickerView;
}
推荐答案
UIPickerView继承自UIView,因此您应该能够只切换其"hidden"属性:
UIPickerView inherits from UIView, so you should be able to just toggle its 'hidden' property:
if (pickerView) pickerView.hidden = !pickerView.hidden;
这篇关于隐藏/显示UIPickerView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文