美文网首页
2018-01-30

2018-01-30

作者: 张择端 | 来源:发表于2018-01-30 13:46 被阅读5次

Swift xcode9.1 初见

@IBOutlet weak var picker: UIPickerView!

 let beauties = ["范冰冰","李冰冰","王菲","杨幂","周迅"]

picker.delegate = self as UIPickerViewDelegate 

 picker.dataSource = self

//页面跳转的方法(xib)

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

        if segue.identifier == "GoToGallery" {

            let index = picker.selectedRow(inComponent: 0)

            var imageName: String?

            switch index{

            case 0:

                imageName = "fanbingbing"

            case 1:

                imageName = "libingbing"

            case 2:

                imageName = "wangfei"

            case 3:

                imageName = "yangmi"

            case 4:

                imageName = "zhouxu"

            default:

                imageName = nil

            }

            let vc = segue.destination as! GalleryViewController

            vc.imageName = imageName 

        }

    //页面返回

  @IBAction func close(segue: UIStoryboardSegue) {

    }

}

新建文件viewcontrollerextension()

extension ViewController : UIPickerViewDataSource{

    func numberOfComponents(in pickerView: UIPickerView) -> Int {

        return 1

    }   

    public func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int{        return beauties.count

    }

}

extension ViewController : UIPickerViewDelegate{

    public func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String?{

        return beauties[row]

    }

}

相关文章

  • 2018-01-31

    2018-01-30 路易彬彥张娟 2018-01-30 21:48 · 字数 760 · 阅读 4 · 日记本 ...

  • 2018-01-30

    打败灯叔叔的路上经过…… ybrybr 2018-01-30 20:35 · 字数 265 · 阅读 0 · 日记...

  • Python基础学习日志

    2018-01-30 一、函数 1.替换空格、杠号,例: def replaceinfo(oldname): n...

  • 新时代. 朝阳

    2018-01-30 ——岁月如歌诗词选(第二集. 34) 读王跃春《...

  • 天下美王(歌词)

    天下美王 演唱:凤凰 人气:1319134 作词:群星 作曲:群星 上传: 2018-01-30 献花:63 00...

  • 六项精进

    日精进打卡25天 龚璟明 已关注 2018-01-30 22:44 · 字数 214 · 阅读 5 · 日记本 日...

  • 无题

    2018-01-30 舞文弄墨消寒图,企暖盼春数九九。 浮想联翩雪夜梦,文人雅士竞风流。

  • 字数 1213 · 阅读 15 2018-01-30 19:28 秋姑娘轻轻地走了,调皮的冬弟弟却又带着可...

  • 交叉编译boost库

    转载 boost库的交叉编译 2018-01-30 18:32:21 揽星逐月酒微醺 阅读数 374 收藏 更多...

  • 2018-01-30周二祷告词

    2018-01-30为孩子祷告: 蒙主引导!(创31:3) 【经文】【创 31:3】 耶和华对雅各说:“你要回你祖...

网友评论

      本文标题:2018-01-30

      本文链接:https://www.haomeiwen.com/subject/mfqczxtx.html