Cli*_*ner 2 iphone uitextfield ipad ios
我把它缩小到只有IOS6设备.
原始问题:
我到处搜索并尝试了一切,我根本想不出来!
我有一个UITextField.选中后,键盘向上滑动,光标在文本字段上开始闪烁.当我点击键盘上的按钮时,一切都正常,键响应,光标停止闪烁.唯一的问题是文本没有放入文本字段!然而,它接受来自表情符号键盘的输入.任何帮助将非常感谢!
这是如何UITextField创建的:
UITextField *userInput = [[UITextField alloc] initWithFrame:CGRectMake(10, yPos, controlWidth, 26)];
yPos += 32;
[userInput setText:[prompt defaultValue]];
[userInput setPlaceholder:[prompt helpText]];
[userInput setBorderStyle:UITextBorderStyleRoundedRect];
[userInput setClearButtonMode:UITextFieldViewModeWhileEditing];
[userInput setFont:[UIFont fontWithName:@"Helvetica" size:18]];
[userInput setAdjustsFontSizeToFitWidth:YES];
[userInput setMinimumFontSize:10];
[userInput setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[userInput setDelegate:self];
[self.scrollView addSubview:userInput];
[self.promptControls addObject:userInput];
[userInput release];
Run Code Online (Sandbox Code Playgroud)
这是一个for循环所以UITextFields 的数量取决于循环被调用的次数.
这些是我使用的委托方法:
- (void)textFieldDidBeginEditing:(UITextField *)aTextField
{
self.activeField = aTextField;
}
- (void)textFieldDidEndEditing:(UITextField *)aTextField
{
self.activeField = nil;
}
- (BOOL)textFieldShouldReturn:(UITextField *)aTextField
{
[aTextField resignFirstResponder];
return YES;
}
Run Code Online (Sandbox Code Playgroud)
activeField 是视图控制器上的属性,用于确定当前活动的字段
我相信这就是所有相关的代码
确保在启动时正确设置窗口
而你正在打电话
[window setRootViewController:someViewController];
如果你不这样做,iOS6中现在出现错误......
[window makeKeyAndVisible];
这不是一个错误(省略),而是把事情扔进了荒芜的土地,似乎导致UITextView并且UITextField不能很好地运作.
如......
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.viewController = [[[MyViewController alloc] initWithNibName:nil bundle:nil] autorelease];
self.navigationController = [[[UINavigationController alloc] initWithRootViewController:self.viewController] autorelease];
[window setRootViewController:navigationController];
[window makeKeyAndVisible];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2527 次 |
| 最近记录: |