-3
UITextField
在iOS8中不起作用,点击文本框时没有看到键盘,也没有看到任何崩溃。但它在iOS7设备上工作正常。 我使用的是以下代码:UITextField无法在IOS8中工作
UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"TF_MSG_ ENTER", @"") message:@"\n\n" delegate:self cancelButtonTitle:NSLocalizedString(@"TF_CANCEL_TEXT", @"") otherButtonTitles:NSLocalizedString(@"TF_MSG_ OK", @""), nil];
UITextField *txBookmarkName = nil;
if ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0)
{
txBookmarkName = [[UITextField alloc] initWithFrame:CGRectMake(12.0f, 45.0f, 260.0f, 25.0f)];
myAlert.alertViewStyle = UIAlertViewStylePlainTextInput;
txBookmarkName = [myAlert textFieldAtIndex:0];
}
else
{
txBookmarkName = [[UITextField alloc] initWithFrame:CGRectMake(12.0f, 45.0f, 260.0f, 25.0f)];
IF_PRE_IOS4 (
[txBookmarkName release], txBookmarkName = nil;
txBookmarkName = [[UITextField alloc] initWithFrame:CGRectMake(12.0f, 65.0f, 260.0f, 25.0f)];
);
}
[txBookmarkName setDelegate:self];
[txBookmarkName setText:nameLabel.text];
myAlert.tag=TF_TAG_TEXT_FIELD_RENAME;
[txBookmarkName setBorderStyle:UITextBorderStyleRoundedRect];
[txBookmarkName becomeFirstResponder];
[txBookmarkName setAutocorrectionType:UITextAutocorrectionTypeNo];
txBookmarkName.tag=TF_TAG_TEXTFIELD;
[myAlert addSubview: txBookmarkName];
[myAlert setFrame:CGRectMake(0, 0, 300,50)];
IF_PRE_IOS4 (
CGAffineTransform t = CGAffineTransformMakeTranslation(0.0f, 85.0f);
[myAlert setTransform: t];
);
[myAlert show];
[txBookmarkName release];
if ([[UIDevice currentDevice].systemVersion floatValue] < 7.0)
[myAlert release];
请帮帮我。
在此先感谢。
你使用模拟器来测试它吗? – 2014-09-24 10:17:45
它不工作在模拟器以及设备也... – 2014-09-24 10:23:32
是UITextField的userInteractionEnabled和启用属性设置为YES? – 2014-09-24 10:26:59