iPhone:键盘没有隐藏
我有一种情况,我有一个警报视图,其中以编程方式绘制了一个文本字段,
UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:@"Welcome" message:@"Enter you name" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
nameField = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)];
[nameField setBorderStyle:UITextBorderStyleRoundedRect];
[nameField setPlaceholder:@"Enter Owners name"];
[nameField setTextAlignment:UITextAlignmentCenter];
[nameField setDelegate:self];
[nameField setBackgroundColor:[UIColor clearColor]];
[alertView addSubview:nameField];
CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0.0, -80.00);
[alertView setTransform: moveUp];
[alertView show];
[alertView release];
以隐藏我使用过的键盘
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return YES;
}
,但键盘没有隐藏。请帮助我。
I have a situation, I have an alertview with one textfield drawn in it programmatically
UIAlertView *alertView=[[UIAlertView alloc] initWithTitle:@"Welcome" message:@"Enter you name" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
nameField = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)];
[nameField setBorderStyle:UITextBorderStyleRoundedRect];
[nameField setPlaceholder:@"Enter Owners name"];
[nameField setTextAlignment:UITextAlignmentCenter];
[nameField setDelegate:self];
[nameField setBackgroundColor:[UIColor clearColor]];
[alertView addSubview:nameField];
CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0.0, -80.00);
[alertView setTransform: moveUp];
[alertView show];
[alertView release];
to hide the keyboard I have used this
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return YES;
}
but keyboard is not hiding. Please help me in this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用它隐藏键盘。当单击模拟器/仿真器/iOS 设备的背景时,这将起作用。
You can hide your keyboard using this. This will work when clicking the background of your simulator/emulator/iOS-device.