但是,我想知道在这些事件之前键盘的预期高度,所以我可以在视图控制器的vIEwDIDLoad上设置某些设计元素.
由于设备正在改变,新的拼写校正条改变了键盘高度,我不想硬编码高度.
有没有人知道如何从键盘获得预期的高度考虑到它是否有自动纠正等?
解决方法@H_502_11@ 您可以通过以下方式完成:- (voID)vIEwDIDLoad {[super vIEwDIDLoad];[self initializeTextVIEw];
}
– (无效)initializeTextVIEw {
// Listen for keyboard appearances and disappearances[[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(keyboardDIDShow:) name:UIKeyboardDIDShowNotification object:nil];[[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(keyboardDIDHIDe:) name:UIKeyboardDIDHIDeNotification object:nil];mycoloredTextvIEw = [[UITextVIEw alloc]initWithFrame:CGRectMake(0,20,300,100)];mycoloredTextvIEw.delegate = self;[self.vIEw addSubvIEw:mycoloredTextvIEw];mycoloredTextvIEw.backgroundcolor = [UIcolor lightGraycolor];}- (voID)keyboardDIDShow: (NSNotification *) notif{// Do something here NSLog(@"show:%@",notif); NSDictionary *userInfo = [notif valueForKey:@"userInfo"]; CGRect kbFrame = [[userInfo objectForKey:@"UIKeyboardFrameBeginUserInfoKey"] CGRectValue]; NSLog(@"keboardHeight:%f",kbFrame.size.height);
}
- (voID)keyboardDIDHIDe: (NSNotification *) notif{// Do something hereNSLog(@"hIDe:%@",notif);
}
总结以上是内存溢出为你收集整理的iOS iPhone – 在键盘上显示UIKeyboard高度全部内容,希望文章能够帮你解决iOS iPhone – 在键盘上显示UIKeyboard高度所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)