【发布时间】:2014-12-10 04:41:22
【问题描述】:
问题:
UIAlertView 在 iOS8 中只显示一行键盘
这是我的代码:
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
UITextField *txtName = nil;
if(buttonIndex == 1){ // save project name
txtName = (UITextField *)[alertView textFieldAtIndex:0];
if(txtName && txtName.text && [txtName.text length] > 0 && ![txtName.text isEqualToString:@" "]) {
//SPAppDelegate *appdelegate = (SPAppDelegate*)[[UIApplication sharedApplication] delegate];
NSString *filePath = nil;
//if(![appdelegate isProjectNameAlreadyExist:txtName.text]){
if(![SPUtility isProjectNameAlreadyExist:txtName.text]){
//filePath = [appdelegate getProjectPathWthName:txtName.text];
filePath = [SPUtility getProjectPathWthName:txtName.text];
[self loadProjectList];
}
else{
[[[UIAlertView alloc] initWithTitle:@"Error" message:@"Project name already exists." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
}
}
else{
[[[UIAlertView alloc] initWithTitle:@"Error" message:@"Project name is empty." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
}
}
}
问题一定出在这里***
-(void) launchProjectNameInputAlert{
/*_alertView = nil;
_alertView = [[UIAlertView alloc] initWithTitle:@"test" message:@"test1" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[_alertView show];*/
_isShowAlert = YES; //boolean variable
//_alertView =[[UIAlertView alloc] initWithTitle:@"ADD item" message:@"Put it blank textfield will cover this" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@" " message:@" " delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
UITextField *txtName = [alertView textFieldAtIndex:0];
txtName.text=@"";
//txtName.tag = 1000;
//[txtName setBackgroundColor:[UIColor blackColor]];
[txtName setKeyboardAppearance:UIKeyboardAppearanceAlert];
[txtName setAutocorrectionType:UITextAutocorrectionTypeNo];
[txtName setTextAlignment:NSTextAlignmentLeft];
txtName.placeholder = @"Project Name";
[alertView addSubview:txtName];
[alertView show];
}
有人可以检查一下吗?
这里是Image的链接供参考。
【问题讨论】:
-
您能否提供一张图片或更好地阐述您的问题。脱离上下文时,您的代码毫无意义。你只显示键盘的一行是什么意思我假设它是一个文本字段但不确定,无论哪种方式,我们都不知道你的愿景是什么或你想要发生什么。
-
我没有足够的声望在这里发送图片。我的视频编辑器上我的项目列表的警报弹出窗口现在在 ios7 上工作,现在在 ios8 上它只是弹出并显示一行您将在其中键入项目的行。您可以键入任何内容来制作项目。这是标准的 iOS 警报弹出窗口
-
你可以链接图片供参考
-
删除这一行:
[alertView addSubview:txtName];,因为文本字段已经是一个子视图。
标签: ios objective-c uialertview