有什么办法可以判断 UIPickerView 是否在旋转? [英] Is there any way to tell if UIPickerView is spinning?

查看:66
本文介绍了有什么办法可以判断 UIPickerView 是否在旋转?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以判断 UIPickerView 是否在旋转?我需要在转换时禁用一些 UI 元素.

Is there any way to tell if UIPickerView is spinning? I need to disable some UI elements when it is in transition.

推荐答案

我通过在 didSelectRow 中保存行号并将其与 selectedRowInComponent 中的行进行比较来解决它.

I solved it by saving the row number in didSelectRow and comparing it to the row in selectedRowInComponent.

-(BOOL) isCardPickerSpinning{
return (lastCardPickerRow != [cardPicker selectedRowInComponent:0]);}

我还创建了一个布尔值,用于在微调器启动时调用方法.

I also created a boolean that will be used to call a method when the spinner is put in motion.

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row
  inComponent:(NSInteger)component
{
 lastCardPickerRow = row;
 pickerInMotion = NO;
 //update UI code goes here
 eventSwitch.enabled = YES;
}

 -(void)pickerViewMotionStart
{
    //disable my UI
    eventSwitch.enabled = NO;
}

- (UIView *)pickerView:(UIPickerView *)pickerView
        viewForRow:(NSInteger)row
      forComponent:(NSInteger)component
       reusingView:(UIView *)view {

UILabel *pickerLabel = (UILabel *)view;
 if (pickerLabel == nil) {
    CGRect frame = CGRectMake(0.0, 0.0, 200, 32);
    pickerLabel = [[UILabel alloc] initWithFrame:frame];
    pickerLabel.textAlignment=NSTextAlignmentLeft;
 }
 if (!pickerInMotion)
 {
    pickerInMotion = YES;
    [self pickerViewMotionStart];
 }
 pickerLabel.text = @"SomeString";
 return pickerLabel;

}

这篇关于有什么办法可以判断 UIPickerView 是否在旋转?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆