我有5个下拉列表。我想按以下方式打开和关闭该drodownlist(UIView):
1.如果单击第一个按钮,它将打开下拉列表,第二次单击它将关闭。
2.如果在第一个按钮上单击打开了一个下拉列表,而我在第二个按钮上单击,则第一个下拉列表将关闭,第二个下拉列表将打开。
我能够以(1)的方式打开和关闭下拉列表。但在第二种情况下我无法。
这是我的代码。
if ([self.DropDownView isDescendantOfView:self.view])
{
[self dropDownCloseAnimation:sender withTF:nil];
[self.DropDownView removeFromSuperview];
// [self performSelector:@selector(showMenu:) withObject:sender afterDelay:0.1];
}
else
{
[self.SinupView addSubview:self.DropDownView];
[self dropDownAnimation:sender withTF:nil];
}
这是动画下拉列表的功能
-(void)dropDownCloseAnimation : (UIButton *)sender withTF : (UITextField *)textField
{
if (sender.tag == 203 || textField.tag == 106)
{
[UIView animateWithDuration:0.9 animations:^{
self.DropDownView.frame = CGRectMake(self.TFVehicalType.frame.origin.x, self.TFVehicalType.frame.origin.y + self.TFVehicalType.frame.size.height + 2, self.TFVehicalType.frame.size.width, 0);
} completion:nil];
}
else if (sender.tag == 204 || textField.tag == 107)
{
[UIView animateWithDuration:0.5 animations:^{
self.DropDownView.frame = CGRectMake(self.TFVehicalColor.frame.origin.x, self.TFVehicalColor.frame.origin.y + self.TFVehicalColor.frame.size.height + 2, self.TFVehicalColor.frame.size.width, 0);
} completion:nil];
}
else if (sender.tag == 205 || textField.tag == 112)
{
[UIView animateWithDuration:0.5 animations:^{
self.DropDownView.frame = CGRectMake(self.TFCity.frame.origin.x, self.TFCity.frame.origin.y + self.TFCity.frame.size.height + 2, self.TFCity.frame.size.width, 0);
} completion:nil];
}
else if (sender.tag == 206 || textField.tag == 113)
{
[UIView animateWithDuration:0.5 animations:^{
self.DropDownView.frame = CGRectMake(self.TFLocation.frame.origin.x, self.TFLocation.frame.origin.y + self.TFLocation.frame.size.height + 2, self.TFLocation.frame.size.width, 0);
} completion:nil];
}
else if (sender.tag == 207 || textField.tag == 114)
{
[UIView animateWithDuration:0.5 animations:^{
self.DropDownView.frame = CGRectMake(self.TFStatus.frame.origin.x, self.TFStatus.frame.origin.y + self.TFStatus.frame.size.height + 2, self.TFStatus.frame.size.width, 0);
} completion:nil];
}
}
1-制作一个数组
2-在屏幕上显示每个下拉列表后,将其添加到数组中
3-在按下打开/关闭任何下拉菜单的操作中,在我们刚刚做过的数组上循环
4-并关闭每次迭代的每个下拉列表
5-打开发件人之一。
祝您编码愉快!
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句