Swift development of the call system album

Source: Internet
Author: User

I think everyone is familiar with the ability to call system albums in IOS , but the Swift language call may not be very clear to many partners, after all, Swift is a new language, so the syntax and implementation may not be very clear, So today do a demo, we can do a reference.



//

Viewcontroller.swift

Ios

//

Created by Yue technology on 15/1/12.

Copyright (c) year BSY. All rights reserved.

//


Import UIKit


Class Viewcontroller:uiviewcontroller, uiimagepickercontrollerdelegate,uinavigationcontrollerdelegate{


Override Func Viewdidload () {

Super.viewdidload ()

Create UIButton

var Button:uibutton = UIButton ()

Set Frame

var frame = CGRectMake (100, 60, 100, 60)

Button.frame = Frame

Set Font Color

Button.settitlecolor (Uicolor.redcolor (), ForState:UIControlState.Normal)

Set Font

Button.settitle (" point I have surprise ", ForState:UIControlState.Normal)

Add Method

Button.addtarget (Self, Action: "ButtonClick", ForControlEvents:UIControlEvents.TouchUpInside)

Add to Parent control

Self.view.addSubview (Button)

}


/**

Implementing the button method

*/

Func ButtonClick () {

var pick:uiimagepickercontroller = Uiimagepickercontroller ()

Pick.delegate = Self

Self.presentviewcontroller (pick, Animated:true, Completion:nil)

}

/**

Implementing Proxy Methods Uiimagepickercontrollerdelegate,uinavigationcontrollerdelegate


*/

Func Imagepickercontroller (Picker:uiimagepickercontroller, didfinishpickingmediawithinfo info: [nsobject:anyobject ]) {

var Imageview:uiimageview = Uiimageview (frame:cgrectmake (0, 100, 320, 300))

Let Gotimage = Info[uiimagepickercontrolleroriginalimage] as UIImage

Imageview.image = Gotimage

Self.view.addSubview (ImageView)

println (info);

Self.dismissviewcontrolleranimated (True, Completion:nil);

}

/**

Implementing Proxy Methods Uiimagepickercontrollerdelegate,uinavigationcontrollerdelegate

*/

Func Imagepickercontrollerdidcancel (Picker:uiimagepickercontroller) {

}


}





Swift development of the call system album

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.