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