ios - UIPicker as input for UITextfield keyboard -


initially wanted implement picker upon selecting uitableviewcell or uilabel.

the best approach 1. subclass uitextfield , set inputview picker. 2. make textfield becomefirstresponder in didselectrowatindexpath

answer below

the inputview attribute assign picker view textfield's first responder. won't display pickerview. therefore, warmuptextfield.inputview = picker should moved viewdidload().

what expect in didselectrowatindexpath set textfield first responder. code below function should work expect.

override func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) {          if indexpath.section == 0 {              nametexfield.becomefirstresponder()          } else if indexpath.section == 1 {              warmuptextfield.becomefirstresponder()          }     } 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

how does one get csharp-sqlite to throw exceptions for duplicates or foreign key constraint violations -

Simple Angular 2 project fails 'Unexpected reserved word' -