switch statement - Trying to set a textField on top of a keyboard in swift -


i trying set textfield on top of keyboard programmatically in swift. using switch statement determine size screen user on affect size of keyboard , textfield should place. code not running can help.

i still trying head around swift.

 var mytextfield : uitextfield!         var windowheight = uiscreen.mainscreen().bounds.size.width          switch windowheight {         case 667:             //iphone 6 , 6+             mytextfield = uitextfield(frame: cgrect(x: 20, y: view.frame.size.height - 258.0, width: view.frame.size.width - 40, height: 40.00))         case 568:             //iphone 5 5s , 6zoom             mytextfield = uitextfield(frame: cgrect(x: 20, y: view.frame.size.height - 253.0, width: view.frame.size.width - 40, height: 40.00))         default:             //segue or alert view here             println("the screen size incorrect")         }          mytextfield.becomefirstresponder()         mytextfield.borderstyle = uitextborderstyle.line          self.view.addsubview(mytextfield) 

thanks

don't bother calculating exact screen heights. instead use category animate view automatically.

https://github.com/lazerwalker/mwkeyboardanimation


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -