Get the current first responder without using a private API

前端 未结 28 2504
夕颜
夕颜 2020-11-22 05:03

I submitted my app a little over a week ago and got the dreaded rejection email today. It tells me that my app cannot be accepted because I\'m using a non-public API; specif

28条回答
  •  猫巷女王i
    2020-11-22 06:06

    This is what I did to find what UITextField is the firstResponder when the user clicks Save/Cancel in a ModalViewController:

        NSArray *subviews = [self.tableView subviews];
    
    for (id cell in subviews ) 
    {
        if ([cell isKindOfClass:[UITableViewCell class]]) 
        {
            UITableViewCell *aCell = cell;
            NSArray *cellContentViews = [[aCell contentView] subviews];
            for (id textField in cellContentViews) 
            {
                if ([textField isKindOfClass:[UITextField class]]) 
                {
                    UITextField *theTextField = textField;
                    if ([theTextField isFirstResponder]) {
                        [theTextField resignFirstResponder];
                    }
    
                }
            }
    
        }
    
    }
    

提交回复
热议问题