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