iOS Development--Practical technical article Swift & photo

Source: Internet
Author: User

Photo

1     //MARK:-Take pictures2 func fromphotograph ()3     {4         ifuiimagepickercontroller.issourcetypeavailable (. Camera)5         {6             //Create a picture controller7Let picker =Uiimagepickercontroller ()8             9             //Set up proxyTenPicker.Delegate= Self One              A             //Set Source -Picker.sourcetype =Uiimagepickercontrollersourcetype.camera -              the              -             //Setting the lens -             ifuiimagepickercontroller.iscameradeviceavailable (Uiimagepickercontrollercameradevice.front) -             { +Picker.cameradevice =Uiimagepickercontrollercameradevice.front -             } +              A             //Setting the Flash atPicker.cameraflashmode =Uiimagepickercontrollercameraflashmode.on -              -             //Allow Editing -Picker.allowsediting =true; -              -             //turn on the camera inSelf.presentviewcontroller (picker, animated:true, completion: {(), Voidinch -                  to             }) +              -         } the         Else *         { $Let Aler = Uialertview (title:"can't find the camera!", Message:nil,Delegate: Nil, Cancelbuttontitle:"Determine")Panax Notoginseng aler.show () -         } the     } +      A     //MARK:-Uiimagepickercontrollerdelegate the      +     //Select image after successful agent - func Imagepickercontroller (picker:uiimagepickercontroller, didfinishpickingmediawithinfo info: [NSOBJECT:ANYOB Ject]) $     { $         //View Info Object - println (Info) -          the         //get the selected artwork - //Let image = Info[uiimagepickercontrolleroriginalimage] as UIImageWuyi          the         //May 2015 after 2 revision -Let image = Info[uiimagepickercontrolleroriginalimage] as!UIImage Wu          -         //assignment, picture view display Picture AboutPicview.image =Image $          -         //Picture Controller Exit -Picker.dismissviewcontrolleranimated (true, completion: {(), Voidinch -              A         }) +     } the      -     //canceling the picture controller agent $ func imagepickercontrollerdidcancel (picker:uiimagepickercontroller) the     { the         //Picture Controller Exit thePicker.dismissviewcontrolleranimated (true, completion: {(), Voidinch the              -         }) in     } the      the      About     //MARK:-Uiactionsheetdelegate the func actionsheet (Actionsheet:uiactionsheet, Clickedbuttonatindex buttonindex:int) the     { the         ifButtonindex! =Actionsheet.cancelbuttonindex +         { -             ifButtonindex = =1  //Select from albums the             {Bayi self.fromalbum () the}Else ifButtonindex = =2 //Take Pictures the             { - self.fromphotograph () -             } the         } the}

iOS Development--Practical technical article Swift & photo

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.