繁体   English   中英

保持选择模式,直到在uitextfield中输入文本

[英]Keep in select mode untill entering text in uitextfield

我在uitableviewcell中有两个文本字段,并且我选择了一个单元格,我必须保持该单元格处于选中状态,直到输入文本为止,我不想让光标进入下一个字段,而不必输入文本。

[self.playerTable.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx,BOOL*stop)
     {  //UITableViewCell *cell = obj;
         UITableViewCell *cell1 = (UITableViewCell *)[tableView cellForRowAtIndexPath:indexPath];

         if([cell1 isKindOfClass:[UITableViewCell class]])
         {
             for(UITextField *textField in cell1.contentView.subviews)
             {
                 [textField resignFirstResponder];
                 if([textField isKindOfClass:[UITextField class]])
                 {
                     textField.userInteractionEnabled = YES;
                     [textField resignFirstResponder];
                 }

             }

         }
     } ]; 

您可以使用textfield委托方法找到它

    - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{

        if (secondTextField == textField && [[firstTextField text] length]==0) {
            //No text on first text field
            [firstTextField becomeFirstResponder];
            return NO;
        }

        if (secondTextField == textField && [[secondTextField text] isEqualToString:[firstTextField text]]) {
            // Same text
            [firstTextField becomeFirstResponder];
            return NO;

        }
        return YES;
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM