Swift 简单控件示例:选择器(UIPickerView)

Swift 简单控件示例:选择器(UIPickerView),第1张

概述转载请声明出处:http://blog.csdn.net/jinnchang/article/details/44618813 ------------------------------------------------------------------------------------------ //// ViewController.swift// UIPickerViewS 转载请声明出处:http://www.jb51.cc/article/p-bwzyycke-ga.html
------------------------------------------------------------------------------------------

////  VIEwController.swift//  UIPickerVIEwSample////  Created by jinnchang on 15/4/2.//  copyright (c) 2015年 Jinn Chang. All rights reserved.//import UIKitclass VIEwController: UIVIEwController,UIPickerVIEwDelegate,UIPickerVIEwDataSource {        var pickerVIEw: UIPickerVIEw!        var hourLength = 24    var minuteLength = 60    overrIDe func vIEwDIDLoad() {        super.vIEwDIDLoad()        // Do any additional setup after loading the vIEw,typically from a nib.                pickerVIEw = UIPickerVIEw(frame: CGRectMake(0,self.vIEw.frame.size.height - 400,self.vIEw.frame.size.wIDth,400))        pickerVIEw.delegate = self        pickerVIEw.dataSource = self                self.vIEw.addSubvIEw(pickerVIEw)    }    overrIDe func dIDReceiveMemoryWarning() {        super.dIDReceiveMemoryWarning()        // dispose of any resources that can be recreated.    }    // 设置个数    func numberOfComponentsInPickerVIEw(pickerVIEw: UIPickerVIEw) -> Int {        return 2    }        // 设置行数    func pickerVIEw(pickerVIEw: UIPickerVIEw,numberOfRowsInComponent component: Int) -> Int {        if(component == 0){            return hourLength        }        if(component == 1){            return minuteLength        }        return 0    }        // 设置每行具体内容    func pickerVIEw(pickerVIEw: UIPickerVIEw,TitleForRow row: Int,forComponent component: Int) -> String! {        if(component == 0){            return "\(row)时"        }        if(component == 1){            return "\(row)分"        }        return nil    }        // 选中行的 *** 作    func pickerVIEw(pickerVIEw: UIPickerVIEw,dIDSelectRow row: Int,inComponent component: Int) {        if(component == 0){            println("hour selected: \(row)")        }        if(component == 1){            println("minute selected: \(row)")        }      }}
------------------------------------------------------------------------------------------
GitHub 上项目地址:UIPickerViewSample
控件更多相关属性及方法参考:UIPickerView Class Reference 文章最后更新时间:2015年4月3日11:15:03
总结

以上是内存溢出为你收集整理的Swift 简单控件示例:选择器(UIPickerView)全部内容,希望文章能够帮你解决Swift 简单控件示例:选择器(UIPickerView)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1088493.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存