Add gestures to pictures, upload photos

Source: Internet
Author: User
Tags uikit

. h

#import <UIKit/UIKit.h>@interface  Rootviewcontroller:uiviewcontroller< Uiactionsheetdelegate,uiimagepickercontrollerdelegate,uinavigationcontrollerdelegate>{    *  ImageView;}

. m

- (void) viewdidload{[Super Viewdidload]; //Do any additional setup after loading the view.Self.title=@"picture gestures, uploading photos"; //initializing the background map[self initbackgroundview]; }#pragma-mark-functions-(void) initbackgroundview{ImageView=[[uiimageview Alloc]initwithframe:cgrectmake ( -, Max, $, Max)]; Imageview.backgroundcolor=[Uicolor Redcolor];        [Self.view Addsubview:imageview];    [ImageView Setuserinteractionenabled:yes]; UITapGestureRecognizer* Clickgesture =[[UITapGestureRecognizer alloc]initwithtarget:self Action: @selector (clickgesture:)]; [ImageView addgesturerecognizer:clickgesture];}#pragma-mark-doclickactions-(void) Clickgesture: (uigesturerecognizer*) gesture{Uiactionsheet*actionsheet = [[Uiactionsheet alloc]initwithtitle:@"Select a picture source" Delegate: Self Cancelbuttontitle:@"Cancel"Destructivebuttontitle:@"Take Pictures"Otherbuttontitles:@"Local Albums", nil]; [Actionsheet ShowInView:self.view];}#pragma-mark uiactionsheetdelegate-(void) Actionsheet: (Uiactionsheet *) Actionsheet Clickedbuttonatindex: (nsinteger) buttonindex{NSLog (@"--buttonindex-%i", Buttonindex); Uiimagepickercontroller*pickview =[[Uiimagepickercontroller alloc]init]; Pickview.Delegate=Self ; if(buttonindex==0&&!target_iphone_simulator) {        //CameraPickview.sourcetype =Uiimagepickercontrollersourcetypecamera;            [Self Presentviewcontroller:pickview animated:no completion:nil]; }Else if(buttonindex==1){        //albumsPickview.sourcetype =uiimagepickercontrollersourcetypephotolibrary;            [Self Presentviewcontroller:pickview animated:no completion:nil]; }}#pragma-mark-uiimagepickercontrollerdelegate-(void) Imagepickercontroller: (Uiimagepickercontroller *) Picker Didfinishpickingmediawithinfo: (NSDictionary *) info{UIImage* Image =[Info objectforkey:uiimagepickercontrolleroriginalimage];    [ImageView Setimage:image];    [Picker Dismissviewcontrolleranimated:no Completion:nil]; }-(void) Imagepickercontrollerdidcancel: (Uiimagepickercontroller *) picker{[picker dismissviewcontrolleranimated:no Completion:nil]; }

Add gestures to pictures, upload photos

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.