菜鸟教程小白 发表于 2022-12-11 18:35:12

ios - 没有在自定义单元格上调用文本字段确实开始编辑


                                            <p><p>我在表格 View 上有自定义单元格。单元格有一个文本字段。例如,如果我有 4 个单元格,每个单元格都带有文本字段。我可以点击三个文本字段,并且相关的文本字段确实开始编辑。但是对于其中一个文本字段,当我点击它时 - 文本字段确实开始编辑并没有被调用。这是我的方法</p>

<pre><code>-(void)textFieldDidBeginEditing:(UITextField *)textField{

          NSString *SelectedIndexString = [
                                       stringForKey:@&#34;SelectedIndex&#34;];
      NSInteger selectionCount = ;
      NSLog(@&#34;%ld&#34;,(long)selectionCount);

            if (selectionCount) {
                self.accountNameTxtField.enabled = NO;
            }
            else{
                self.accountNameTxtField.enabled = YES;


            }
    }

//STTableViewCell

         @interface STTableViewCell () &lt;UITextFieldDelegate&gt;
         - (void)awakeFromNib {
            ;
            radioBtn.alpha = 0; // Initialization code ;
            // Setting the OTP label color to the RGB blue      
            self.OTPLabel.textColor = ;
            // Set delegate to textfield
            self.accountNameTxtField.delegate=self;
          }

- (void)setEditing:(BOOL)editing animated:(BOOL)animated {

    ;
    [ addObserver:self selector:@selector(incomingNotification:) name:@&#34;No Change&#34; object:nil];

    if (!editing)
    {

         radioBtn.alpha = 0;
      isTableviewEditing=NO;
      if (!) {

            self.accountNameTxtField.text = ];
            if (accountNameTxtField.text.length &gt;= 1)
            {
            // Write out the changes.
                descriptionBlank = NO;

                self.authURL.name = self.accountNameTxtField.text;
                ;
            }
            else{
                ;
                ;
                self.accountNameTxtField.text =self.authURL.name;
                descriptionBlank = YES;
            }

      }
      accountNameTxtField.userInteractionEnabled=NO;
      ;
      for (CALayer *layer in accountNameTxtField.layer.sublayers) {
            if ()
            {
                ;
                break;
            }
      }

      progressView.alpha=1.0;
      OTPLabel.alpha=1.0;

    }
    else
    {
         radioBtn.alpha = 1;
      isTableviewEditing=YES;

      for (CALayer *layer in accountNameTxtField.layer.sublayers) {
            if ()
            {
                ;
                break;
            }
      }

      OTPLabel.alpha=0.0;
      progressView.alpha=0.0;
      accountNameTxtField.userInteractionEnabled=YES;

    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    ;
    if (selected) {`selectHilightCount++;
      self.accountNameTxtField.enabled = NO;
    } else {
      self.accountNameTxtField.enabled = YES;
    }`
}
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>请设置委托(delegate)。
喜欢:</p>

<pre><code>cell.txtFld.delegate = self;
</code></pre>

<p>希望对你有帮助。谢谢</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 没有在自定义单元格上调用文本字段确实开始编辑,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/41632707/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/41632707/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 没有在自定义单元格上调用文本字段确实开始编辑