xcode - Fitting UIPicker and 3 text fields on 3.5 and 4 inch devices -
i have (from top bottom) 2 uilabels, 1 uipickerview, 3 uitexfield, , 1 button. given size of picker, upon keyboard appearing overlaps text fields on 3.5 , 4 inch devices. used code pop text fields when keyboard shows, i'm unsure picker. tried hiding upon keyboard it's sudden , user may want change choice can't easily. should picker given size limitations?
override func viewdidload() { super.viewdidload() countypicker.delegate = self countypicker.datasource = self nsnotificationcenter.defaultcenter().addobserver(self, selector: selector("keyboardwillshow:"), name:uikeyboardwillshownotification, object: nil); nsnotificationcenter.defaultcenter().addobserver(self, selector: selector("keyboardwillhide:"), name:uikeyboardwillhidenotification, object: nil); } func keyboardwillshow(sender: nsnotification) { self.view.frame.origin.y -= 150 } func keyboardwillhide(sender: nsnotification) { self.view.frame.origin.y += 150 // countypicker.hidden = true } func numberofcomponentsinpickerview(pickerview: uipickerview) -> int { return 1 } func pickerview(pickerview: uipickerview, numberofrowsincomponent component: int) -> int { return titledata.mdcounties.count } func pickerview(pickerview: uipickerview, didselectrow row: int, incomponent componefnt: int) { // countypicker.alpha = 0.3 selectedcounty = titledata.mdcounties[row].name } func pickerview(pickerview: uipickerview, titleforrow row: int, forcomponent component: int) -> string! { return titledata.mdcounties[row].name! }
place 1 uipickerview , 3 uitexfield in single view , pop entire view when keyboard shows up.
as have written code pop text fields work out.
hope helps you. :)
Comments
Post a Comment