Home for iOS system does not seem to be willing to write an input method,Except for a few oligarchs other than large companies do nothing else。Approaching China's unique Apple ecological platform,Find inside are empty shells,Meaningful applications is really very little of。
Pocketed blog recently is working to write in the first paragraph can really support the iOS platform the code table of double input method,First compatible double nature of the programme is open to the "Chick double",It stepped on a lot of holes,Will send some experience。From now on,Emergency record a hole:
Using the keyboard,Occasionally pop up plugin XXX.XXX.KeyBoardName invalidated Error log and then collapse the keyboard。
Of course,The good news is that it appears almost exclusively on simulators-we all know,Simulator performance is not as good as really is--but all in all the problem is encountered,But the probability is very small indeed,But the problem must be solved,Otherwise users will occasionally Flash when exhaling keyboard keyboard,Especially when suddenly the background program transferred to the front desk。
All right. Talk is cheap, just show me the code :
prior to,Everybody is to add a view to customize keyboard:
1 2 3 4 5 6 |
let nib = UINib(nibName: "Keyboard", bundle: nil) let objects = nib.instantiateWithOwner(self, options: nil) customInterface = objects[0] as! UIView customInterface.frame = view.frame view.addSubview(customInterface) |
Roll out keyboard model itself with the nib on the keyboards added to the default view,We should not do,A new keyboard if you really own view,Then go straight to UIInputViewController of view Property assignment!
so,Correct practice should be:
1 2 3 4 5 |
let nib = UINib(nibName: "Keyboard", bundle: nil) let objects = nib.instantiateWithOwner(self, options: nil) customInterface = objects[0] as! UIView self.inputView = customInterface |
Such,This error will not be repeated。
Custom keyboard height
By the way,Save custom keyboard reference,Because adding constraints so that you can give it,Then we can adjust the fixed value constraint to change the height of the keyboard--change in real time!
1 2 |
heightConstraint = NSLayoutConstraint(item: customInterface, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 0.0, constant: yourKeyboardHeigt) heightConstraint.priority = 999.0 //避免和其他约束冲突! |
Original article written by LogStudio:R0uter's Blog » "Plugin invalidated" ios Customize Keyboard
Reproduced Please keep the source and description link:https://www.logcg.com/archives/1852.html