相关疑难解决方法(0)

self.delegate = self; 这样做有什么不对?

self.delegate = self; 这样做有什么不对?这样做的正确方法是什么?

谢谢,Nir.

码:

(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;
} 
Run Code Online (Sandbox Code Playgroud)

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

iphone delegates self uitextfield

9
推荐指数
1
解决办法
1万
查看次数

标签 统计

delegates ×1

iphone ×1

self ×1

uitextfield ×1