ios8 - iOS 8 Custom Keyboard appear pretty slow -



ios8 - iOS 8 Custom Keyboard appear pretty slow -

i trying build custom keyboard using swift ios 8 , created each button programatically. when switching custom keyboard build-in keyboard, first time it's pretty slow took 2 seconds appear. not exclusively sure if doing correctly. below code , show 2 buttons there lot more:

class keyboardviewcontroller: uiinputviewcontroller { @iboutlet var nextkeyboardbutton: uibutton! @iboutlet var qbutton: uibutton! var buttonfontsize:cgfloat = 22.0 var gapbtwbutton:cgfloat = +7.0 // lot more button below override func updateviewconstraints() { super.updateviewconstraints() // add together custom view sizing constraints here } override func viewdidload() { super.viewdidload() setupenkeyboard() } func setupenkeyboard(){ println("setupenkeyboard") addenkeyboardbuttons() } func addenkeyboardbuttons() { addqbutton() addnextkeyboardbutton() // lot more button added } func setupbutton(label: string, functionname: selector, imageonbutton: string) -> uibutton { // initialize button allow keybutton:uibutton = uibutton.buttonwithtype(.system) uibutton var testvar: string? = imageonbutton if imageonbutton.isempty { keybutton.settitle(label, forstate: .normal) } else { allow image = uiimage(named: imageonbutton) uiimage keybutton.setimage(image, forstate: .normal) } keybutton.sizetofit() keybutton.settranslatesautoresizingmaskintoconstraints(false) // adding callback keybutton.addtarget(self, action: functionname, forcontrolevents: .touchupinside) // create font bigger keybutton.titlelabel?.font = uifont.systemfontofsize(self.buttonfontsize) // add together rounded corners keybutton.backgroundcolor = uicolor(white: 0.9, alpha: 1) keybutton.settitlecolor(uicolor.blackcolor(), forstate: .normal) keybutton.layer.cornerradius = 5 homecoming keybutton } func addqbutton() { qbutton = setupbutton("q", functionname:"didtapqbutton", imageonbutton:"") view.addsubview(qbutton) var leftsideconstraint = nslayoutconstraint(item: qbutton, attribute: .left, relatedby: .equal, toitem: view, attribute: .left, multiplier: 1.0, constant: +6.0) var topconstraint = nslayoutconstraint(item: qbutton, attribute: .top, relatedby: .equal, toitem: view, attribute: .top, multiplier: 1.0, constant: +10.0) view.addconstraints([leftsideconstraint, topconstraint]) } func didtapqbutton(){ var proxy = textdocumentproxy uitextdocumentproxy proxy.inserttext("q") } func addnextkeyboardbutton() { nextkeyboardbutton = setupbutton("n", functionname:"advancetonextinputmode", imageonbutton:"globe") view.addsubview(nextkeyboardbutton) var leftsideconstraint = nslayoutconstraint(item: nextkeyboardbutton, attribute: .left, relatedby: .equal, toitem: shownumbersbutton, attribute: .right, multiplier: 1.0, constant: self.gapbtwbutton) var bottomconstraint = nslayoutconstraint(item: nextkeyboardbutton, attribute: .bottom, relatedby: .equal, toitem: view, attribute: .bottom, multiplier: 1.0, constant: -3.0) view.addconstraints([leftsideconstraint, bottomconstraint]) } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated } override func textwillchange(textinput: uitextinput) { // app alter document's contents. perform preparation here. } override func textdidchange(textinput: uitextinput) { // app has changed document's contents, document context has been updated. var textcolor: uicolor var proxy = self.textdocumentproxy uitextdocumentproxy if proxy.keyboardappearance == uikeyboardappearance.dark { textcolor = uicolor.whitecolor() } else { textcolor = uicolor.blackcolor() } //self.nextkeyboardbutton.settitlecolor(textcolor, forstate: .normal) } }

appreciate comment please :)

thanks, mark thien

ios8

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -