Uygulamanızın portrede olmasını istediğinizi varsayalım, çünkü manzara varsa değişiklikleri yapabilirsiniz. Uçunuza UIPickerView
ekleyin ve bir IBOutlet
'e bağlayın. Ardından UIPickerView
'i canlandıran IBAction
yöntemiyle bir düğme oluşturun. .H dosyasında deneyin:
@interface MyViewController: UIViewController {
BOOL _pickerIsVisible;
IBOutlet UIPickerView * _picker;
}
- (IBAction)buttonMethod:(UIButton *)aButton;
ve .m dosyasında:
- (void)viewDidLoad; {
[super viewDidLoad];
_pickerIsVisible = NO;
}
- (IBAction)buttonMethod:(UIButton *)aButton; {
if(_pickerIsVisible){
_pickerIsVisible = NO;
[UIView animateWithDuration:2.0f
animations:^{
CGPoint point = _picker.frame.origin;
point.y += 216;//The height of the picker.
_picker.frame.origin = point;
}
completion:^(BOOL finished){
//Do something here if you want.
}];
}
else{
_pickerIsVisible = YES;
[UIView animateWithDuration:2.0f
animations:^{
CGPoint point = _picker.frame.origin;
point.y -= 216;//The height of the picker.
_picker.frame.origin = point;
}
completion:^(BOOL finished){
//Do something here if you want.
}];
}
}
480'in bir y koordinatına sahip olmak için UIPickerView
'nuzu belirlediğinizden emin olun, bu yüzden görünümün altındadır.
Edit: If you want the UIPickerView
to be hooked up and act like the keyboard of a UITextField
or UITextView
, you could always hook it up to the .inputView
property of the UITextField
, and that would work as well.
Umarım yardımcı olur!