<tfoot id='eqX25'></tfoot>
<i id='eqX25'><tr id='eqX25'><dt id='eqX25'><q id='eqX25'><span id='eqX25'><b id='eqX25'><form id='eqX25'><ins id='eqX25'></ins><ul id='eqX25'></ul><sub id='eqX25'></sub></form><legend id='eqX25'></legend><bdo id='eqX25'><pre id='eqX25'><center id='eqX25'></center></pre></bdo></b><th id='eqX25'></th></span></q></dt></tr></i><div id='eqX25'><tfoot id='eqX25'></tfoot><dl id='eqX25'><fieldset id='eqX25'></fieldset></dl></div>
    • <bdo id='eqX25'></bdo><ul id='eqX25'></ul>

    <small id='eqX25'></small><noframes id='eqX25'>

    <legend id='eqX25'><style id='eqX25'><dir id='eqX25'><q id='eqX25'></q></dir></style></legend>

        self.delegate = 自我;这样做有什么问题?

        时间:2023-07-28
        • <i id='YICNd'><tr id='YICNd'><dt id='YICNd'><q id='YICNd'><span id='YICNd'><b id='YICNd'><form id='YICNd'><ins id='YICNd'></ins><ul id='YICNd'></ul><sub id='YICNd'></sub></form><legend id='YICNd'></legend><bdo id='YICNd'><pre id='YICNd'><center id='YICNd'></center></pre></bdo></b><th id='YICNd'></th></span></q></dt></tr></i><div id='YICNd'><tfoot id='YICNd'></tfoot><dl id='YICNd'><fieldset id='YICNd'></fieldset></dl></div>
              <bdo id='YICNd'></bdo><ul id='YICNd'></ul>
                <tfoot id='YICNd'></tfoot>

                    <tbody id='YICNd'></tbody>

                1. <legend id='YICNd'><style id='YICNd'><dir id='YICNd'><q id='YICNd'></q></dir></style></legend>
                2. <small id='YICNd'></small><noframes id='YICNd'>

                  本文介绍了self.delegate = 自我;这样做有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  self.delegate = self; 这样做有什么问题?正确的做法是什么?

                  self.delegate = self; what's wrong in doing that? and what is the correct way of doing it?

                  谢谢,尼尔.

                  代码:

                  (UITextField*)initWith:(id)sender:(float)X:(float)Y:(float)width:(float)hieght:(int)textFieldTag { 
                      if (self = [super initWithFrame:CGRectMake(X, Y,width, hieght)]) {
                          finalText = [[NSMutableString alloc] initWithString:@""];
                          senderObject = sender;
                          self.textColor = [UIColor blackColor]; 
                          self.font = [UIFont systemFontOfSize:17.0]; 
                          self.backgroundColor = [UIColor whiteColor]; 
                          self.autocorrectionType = UITextAutocorrectionTypeNo;   
                          self.keyboardType = UIKeyboardTypeDefault;     
                          self.returnKeyType = UIReturnKeyDone; 
                          self.clearButtonMode = UITextFieldViewModeWhileEditing;    
                          self.tag = textFieldTag;        
                          self.delegate = self;    
                          [sender addSubview:self];
                      }
                      return self;
                  } 
                  

                  注意事项:这是一个文本字段,当我将委托设置为另一个对象(self.delegate = mainView)时,一切正常,但是我必须在mainView,我想把它们放在 self(我创建的一个 uiTextField 类)中.如果我设置 self.delegate = self,我会得到一个 textField 但键盘没有显示.

                  Notes: This is a text field, and when I am setting the delegate to another object (self.delegate = mainView) everything works fine, but then I will have to implement the delegate methods in mainView, and I would like to put them in self (a uiTextField class which I have created). If I am setting self.delegate = self, I do get a textField but the keyboard doesn't show up.

                  推荐答案

                  查看本帖

                  http://www.cocoabuilder.com/archive/cocoa/241465-iphone-why-can-a-uitextfield-be-its-own-delegate.html#241505

                  基本上,当您以自己为委托单击 UITextField 时冻结"的原因是 respondsToSelector 正在调用自身 -> 无限递归.

                  Basically, the reason for the "freeze" when you click on your UITextField with itself as a delegate is that respondsToSelector is calling itself -> infinite recursion.

                  UITextField 是独一无二的 AFAIK.您通常可以使用一个类作为它自己的委托,而没有特别的问题.对于 UITextField,您必须创建一个实际的委托(当然,它可以调用作为委托的 UITextField 上的方法.请注意避免保留循环,即使您使用的是 ARC).

                  UITextField is unique AFAIK. You can usually use a class as its own delegate with no particular problems. For UITextField you must create an actual delegate (that could, of course, call methods on the UITextField for which it's a delegate. Just be careful to avoid retain loops, even if you're using ARC).

                  这篇关于self.delegate = 自我;这样做有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:什么是“代表"?在 Objective C 的 iPhone 开发中? 下一篇:从应用委托中获取当前视图控制器

                  相关文章

                  <small id='KL5YH'></small><noframes id='KL5YH'>

                  • <bdo id='KL5YH'></bdo><ul id='KL5YH'></ul>
                3. <tfoot id='KL5YH'></tfoot>

                    1. <i id='KL5YH'><tr id='KL5YH'><dt id='KL5YH'><q id='KL5YH'><span id='KL5YH'><b id='KL5YH'><form id='KL5YH'><ins id='KL5YH'></ins><ul id='KL5YH'></ul><sub id='KL5YH'></sub></form><legend id='KL5YH'></legend><bdo id='KL5YH'><pre id='KL5YH'><center id='KL5YH'></center></pre></bdo></b><th id='KL5YH'></th></span></q></dt></tr></i><div id='KL5YH'><tfoot id='KL5YH'></tfoot><dl id='KL5YH'><fieldset id='KL5YH'></fieldset></dl></div>
                      <legend id='KL5YH'><style id='KL5YH'><dir id='KL5YH'><q id='KL5YH'></q></dir></style></legend>