大佬教程收集整理的这篇文章主要介绍了显示iPhone软键盘,即使连接了硬件键盘,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我们在AppDelegate中添加了以下两个函数。 ‘inputAccessoryView’变量是我们在应用程序委托中声明的一个UIView *:
//This function responds to all textFieldBegan ediTing // we need to add an accessory view and use that to force the keyboards frame // this way the keyboard appears when the scAnner is attached -(void) textFieldBegan: (Nsnotification *) theNotification { UITextField *theTextField = [theNotification object]; // NSLog(@"textFieldBegan: %@",theTextField); if (!inputAccessoryView) { inputAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0,navigationController.view.frame.size.width,1)]; } theTextField.inputAccessoryView = inputAccessoryView; [self performSELEctor:@SELEctor(forceKeyboard) withObject:nil afterDelay:0]; } //Change the inputAccessoryView frame - this is correct for porTrait,use a different // frame for landscape -(void) forceKeyboard { inputAccessoryView.superview.frame = CGRectMake(0,759,768,265); }
然后在我们的applicationDidFinishLaunching中,我们添加了这个通知观察者,所以我们可以随时收到一个文本字段开始编辑的事件
//Setup the textFieldNotifications [[NsnotificationCenter defaultCenter] addObserver:self SELEctor:@SELEctor(textFieldBegan:) name:UITextFieldTextDidBeginEdiTingNotification object:nil];
希望有帮助!
以上是大佬教程为你收集整理的显示iPhone软键盘,即使连接了硬件键盘全部内容,希望文章能够帮你解决显示iPhone软键盘,即使连接了硬件键盘所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。