情景: cell中有textfield, 现在需要在tableview滚动是取消所有的textfield的第一响应, 一个个写比较麻烦, 写了一个递归方法, 用来遍历所有的子视图.

-(void)allView:(UIView *)rootView {
    for (UIView *subView in [rootView subviews])
    {
        if (!rootView.subviews.count) {
            return;
        }
        if ([subView isKindOfClass:[UITextField class]]) {
            [(UITextField *)subView resignFirstResponder];
        }
        [self allView:subView];
    }
}

 

相关文章:

  • 2021-08-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-29
  • 2021-06-21
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
猜你喜欢
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
  • 2021-10-25
  • 2021-08-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案