我在UIPopover中有一个UITextField。但是,无论我做什么,我都无法输入。如果我在主视图控制器中使用UITextField,它将正常工作。
码:
UITextField *usernameTextField=[[UITextField alloc] initWithFrame:CGRectMake(166.0, 847.0, 100.0, 51.0)];
usernameTextField.secureTextEntry=NO;
[usernameTextField setPlaceholder:@"Username"];
[usernameTextField setAutocorrectionType:UITextAutocorrectionTypeNo];
[usernameTextField setAutocapitalizationType:UITextAutocapitalizationTypeNone];
[usernameTextField setClearButtonMode:UITextFieldViewModeAlways];
[usernameTextField setClearsContextBeforeDrawing:YES];
[usernameTextField setUserInteractionEnabled:YES];
[usernameTextField setEnabled:YES];
usernameTextField.borderStyle = UITextBorderStyleRoundedRect;
usernameTextField.textColor = [UIColor blackColor];
usernameTextField.font = [UIFont systemFontOfSize:17.0];
usernameTextField.keyboardType = UIKeyboardTypeDefault;
usernameTextField.returnKeyType = UIReturnKeySearch;
usernameTextField.delegate=self;
[self.view addSubview:usernameTextField];
任何想法,怎么了?
最佳答案
文本字段是否带有视图控制器?如果没有,您可以尝试这样做,然后使用如下视图控制器初始化UIPopoverController:[[UIPopOverController alloc] initWithContentViewController:yourViewControllerwithTextField];
关于objective-c - UIPopover内的UITextField,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10251362/