UITextField 无法以编程方式工作?

UITextField is not working programmatically?

我以编程方式创建 UITextField 一切正常,但我的 UITextField 没有编辑,即当我尝试点击 UITextField 它在这里不起作用我的示例代码,

CGRect frame = CGRectMake(16, 281, 288, 47);
cycle  = [[UITextField alloc] initWithFrame:frame];
cycle.placeholder = @"Cycle Number";
cycle.textColor = [UIColor blackColor];
cycle.font = [UIFont systemFontOfSize:17.0];
cycle.borderStyle = UITextBorderStyleLine;
cycle.autocorrectionType = UITextAutocorrectionTypeYes;
cycle.keyboardType = UIKeyboardTypeDefault;
cycle.clearButtonMode = UITextFieldViewModeWhileEditing;
cycle.delegate = self;
cycle.text = @"";
[self.view addSubview:cycle];
'UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(10, 200, 300, 40)];   textField.borderStyle = UITextBorderStyleRoundedRect;
textField.font = [UIFont systemFontOfSize:15];
textField.placeholder = @"enter text";
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.keyboardType = UIKeyboardTypeDefault;
textField.returnKeyType = UIReturnKeyDone;
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;    
textField.delegate = self;
[self.view addSubview:textField];'

Below delegate methods must use

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
   [self endEditing];
   [textField resignFirstResponder];
   return YES;

}

- (void)textFieldDidBeginEditing:(UITextField *)textField {
        [self beginEditing:textField];
}

 - (void)textFieldDidEndEditing:(UITextField *)textField {


     // [self endEditing];
}



 I hope you it is useful for u