ios-uploading images to the background

Source: Internet
Author: User

To do the first project, there is a section of the personal information editing related to the Avatar modification, the boss said the project has a common code, let me find. Finally found, engaged for a long time to fix, it seems to understand the ability to improve AH!!

1 #pragmamark-Edit Avatar Upload Save2-(void) Uploadmyico3 {4     //nsstring *filename = @ "Myico.jpg";5UIImage *image1 =Self.headImageVie.image; 6    7NSData *data;8     floatv = image1.size.width/ -;9Cgsize newSize = Cgsizemake (image1.size.width/v, Image1.size.height/v);Ten Uigraphicsbeginimagecontext (newSize); One[Image1 Drawinrect:cgrectmake (0,0, Newsize.width, Newsize.height)]; AUIImage *scaleimage =Uigraphicsgetimagefromcurrentimagecontext (); - Uigraphicsendimagecontext (); -data = UIImageJPEGRepresentation (Scaleimage,0.8); theUIImage *image =[UIImage Imagewithdata:data]; - uiimagewritetosavedphotosalbum (image, nil, nil, nil); -NSString *filenamess =[self createimgfilename]; -nsstring* FilePath =[Nstemporarydirectory () stringbyappendingpathcomponent:filenamess]; + [Data Writetofile:filepath atomically:no]; -Nsmutablearray *imagearray =[[Nsmutablearray alloc]init]; +[Imagearray addobject:[nsdictionary Dictionarywithobject:filepath Forkey:@"file"]]; ASelf.request =Nil; atRequestType =2; -Self.request = [Uprequest uploadPhotoInfo1:@"Member/updatephoto"Image:imagearray KeyName:@"file" Delegate: Selfparams: nil]; -[Skprogressview ShowHudInView:self.view Withtag:2001]; - } -  --(NSString *) Createimgfilename in { -     Static intSeednum =0; to     if(Seednum >= +) +Seednum =0; -seednum++; the      *NSDateFormatter *dateformatter =[[NSDateFormatter alloc] init]; $[Dateformatter Setdateformat:@"YYYYMMDDHHMMSS"];Panax Notoginseng      -NSString *currentdatestr =[dateformatter stringfromdate:[nsdate Date]]; the    //[Dateformatter release]; +      ANSString *file = [NSString stringWithFormat:@"temppics%@%03d.jpg", Currentdatestr, Seednum]; the     returnfile; +}
View Code

ios-uploading images to the background

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.