Giter Club home page Giter Club logo

textfield-inputview's Introduction

image

UITextField+InputView


.Swift 1.2
.Xcode 6.3
.基于MIT开源协议

注:目前大众功能先做这两个,后续有需要再持续追加




单行模型选取集成

1.添加框架

将TextField+PickerView文件夹拖拽到您的项目中
请不要自行设计输入框的代码,因为代理已经被框架使用,如果需要代理,请使用API提供的Closure回调。



2.准备工作

UITextField请继承OneColTF,



3.功能集成

原始值的集成:

    /**  一句代码搞定  */
    tf.addOneColPickerViewWithTitles(["成都","北京","上海","广州"])

模型值集成(注:模型没有强行要求,只要满足PickerDataModelProtocol协议的模型均可):
    let city1 = CityModel(title: "成都市", spell: "ChengDu")
    let city2 = CityModel(title: "南充市", spell: "NanChong")
    let city3 = CityModel(title: "南部县", spell: "NanBu")
    
    /**  一句代码安装  */
    tf.addOneColPickerViewWithModels([city1,city2,city3])



4.取出当前选中的值

得到当前的值, 如果你是原始值,得到的是字符串。 如果是模型值,得到的就是选中的模型。

    let value = tf.selectedPickerViewValue



5.各种设置与事件

移除工具条:

  tf.removeAccessoryView = true

选中事件:

    tf.selectedAction = { row in
    
        println("选中了\(row)行")
    }

点击了完成按钮事件,回调中的value请根据您的类型转换:

    tf.doneBtnActionClosure = { (row,value) in
    
        println("您点击了完成按钮,当前选中第\(row)行,值为\(value)")
    }

5.集成效果

image




模型多选

1.输入框继承自MulSelTF
2.模型需要遵守MulSelTFDataModelProtocol

     let s1 = Service(title: "翻译", isChecked: true,isRequired:true)
     let s2 = Service(title: "司机", isChecked: false,isRequired:false)
     let s3 = Service(title: "公关", isChecked: false,isRequired:false)
     let s4 = Service(title: "导游", isChecked: false,isRequired:false)
     let s5 = Service(title: "商务", isChecked: false,isRequired:false)
      
      tf.addMulSelWithModels([s1,s2,s3,s4,s5])
      
      tf.doneBtnClickClosure = {(all,checked) in
        
        
     }

其中,isChecked表示默认就选中,isRequired表示必选,且isRequired=true下一定会导致isChecked=true



3.集成效果一:普通集成

image



4.集成效果二:更多的选项(可滑动)

image



5.集成效果三:必选模式(如:翻译为必选,不可取消!设置模型的isRequired=true即可)

image



6.集成效果四:取消模式

image




时间选取

1.支持xib,支持代码。

2.请继承自DatePickerTF即可。

3.设置格式化时间的patten,如

    tf.pattern = "yyyy-MM-dd"

4.支持手动设置自定义时间值:

    tf.setDateTimeInterval(1340199504)

5.支持选中事件回调:

    tf.selectedDateClosure = { (picker,dateString,dateInterval) in
    
        println("\(picker),\(dateString),\(dateInterval)")
    }



6.集成效果

image




我的事业

西成的事业,渺小而艰难的求生存。前期我们专做全国的移动app外包。如果您能在信息上援助我们,我们万分感谢您的帮助!
西成:http://ios-android.cn
我的个人微博:http://weibo.com/charlin2015/
GitHub公告:信息公告牌

textfield-inputview's People

Contributors

charlinfeng avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.