iOS解雇键盘,UILabel故障 [英] iOS dismissing keyboard, UILabel malfunction
本文介绍了iOS解雇键盘,UILabel故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发的iOS应用中遇到几个问题。
I'm running into a couple problems in the iOS app I'm developing.
一个是解雇键盘:当它在另外两个屏幕上工作时,有一个屏幕,它不会因某些原因而解雇:
One is dismissing the keyboard: while it works on another two screens, there's one screen where it won't dismiss for some reason:
Login.m
#import "Login.h"
@interface Login()
@end
@implementation Login
-(void) viewdDidLoad{
[super viewDidLoad];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(dismissKeyboard)];
[self.view addGestureRecognizer:tap];
}
-(void)dismissKeyboard {
[_username resignFirstResponder];
[_password resignFirstResponder];
[_birth resignFirstResponder];
}
@end
我的第二个问题是尽管在其他屏幕上工作,屏幕顶部的UILabel仍无法加载:
And my second problem is that the UILabel at top the screen won't load despite working in the other screens:
Login.m
#import "Login.h"
@interface Login()
@end
@implementation Login
-(void) viewdDidLoad{
[super viewDidLoad];
_etiqueta = @"Introdueix el teu nom d'usuari, la contrasenya, i la teva data de naixement";
self.label.text = self.etiqueta;
self.label.numberOfLines = 4;
self.label.textColor = [UIColor blackColor];
}
@end
<我的UILabel也是在故事板上创建的,是IBOutlet,我确保它已正确链接。
My UILabel is created on the storyboard as well, is IBOutlet and I've made sure that it's properly linked.
你能帮我解决这两个问题吗?
Can you help me solve these 2 problems?
推荐答案
使用此方法关闭键盘
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.view endEditing:YES];
}
否则调用 textDelegate
方法
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
这篇关于iOS解雇键盘,UILabel故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文