Call Camera, Album

Source: Internet
Author: User

There is nothing to say, note that the call to the camera when the real-machine test, with the simulator when you want to add a judgment statement, or crash

1 #import "RootViewController.h"2 #import "RootView.h"3 4 @interfaceRootviewcontroller () <uiimagepickercontrollerdelegate, uinavigationcontrollerdelegate>5 6@property (nonatomic, strong) Rootview *Rootview;7 @end8 9 @implementationRootviewcontrollerTen  One- (void) Loadview { ASelf.rootview =[[Rootview alloc] Initwithframe:[uiscreen mainscreen].bounds]; -Self.view =Self.rootview; - } the  -  -  -- (void) Viewdidload { + [Super Viewdidload]; -     //Do any additional setup after loading the view. +      A      at     //Add a Click event - [Self.rootView.cameraButton addtarget:self Action: @selector (Camerabuttonclick:) forControlEvents: UIControlEventTouchUpInside]; -      - [Self.rootView.photoButton addtarget:self Action: @selector (Photobuttonclick:) forControlEvents: UIControlEventTouchUpInside]; - } -  in  -  to #pragmaMark-Implement Click events + //Call Camera -- (void) Camerabuttonclick: (UIButton *) Sender { the      *     //Detecting available Sources $     if([Uiimagepickercontroller Issourcetypeavailable:uiimagepickercontrollersourcetypecamera]) {Panax Notoginseng         //1. Create an object and initialize it -Uiimagepickercontroller *imgpicker =[[Uiimagepickercontroller alloc] init]; the          +         //2. Add a data source AImgpicker.sourcetype =Uiimagepickercontrollersourcetypecamera; the          +         //3. Setting up the agent -Imgpicker.Delegate=Self ; $          $         //4. Whether to allow compilation -Imgpicker.allowsediting =YES; -          the         //5. Implement page Jump - [self presentviewcontroller:imgpicker animated:yes completion:nil];Wuyi}Else { the[Sender Settitle:@"NO"Forstate:uicontrolstatenormal]; -     } Wu } -  About //Implementing Proxy Methods $- (void) Imagepickercontrollerdidcancel: (Uiimagepickercontroller *) Picker { -      - [self dismissviewcontrolleranimated:yes completion:nil]; - } A  +  the  - //Call album $- (void) Photobuttonclick: (UIButton *) Sender { the      the     //1. Create an object and initialize it theUiimagepickercontroller *imgpicker =[[Uiimagepickercontroller alloc] init]; the      -     //2. Add a data source inImgpicker.sourcetype =uiimagepickercontrollersourcetypephotolibrary; the      the     //3. Setting up the agent AboutImgpicker.Delegate=Self ; the      the     //4. Whether to allow compilation theImgpicker.allowsediting =YES; +      -     //5. Implement page Jump the [self presentviewcontroller:imgpicker animated:yes completion:nil];Bayi } the  the @end

Call Camera, Album

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.