拍照-相簿-儲存照片-上傳照片=流程

來源:互聯網
上載者:User

標籤:

 

稍微整理一下

 1 //開啟相機 2 -(void)takePhoto 3 { 4      5     UIImagePickerControllerSourceType sourceType; 6     sourceType = UIImagePickerControllerSourceTypeCamera; 7      8     UIImagePickerController *ipc=[[UIImagePickerController alloc] init]; 9     ipc.sourceType=UIImagePickerControllerSourceTypeCamera;10     ipc.delegate=self;11     //是否可編輯12     ipc.allowsEditing=YES;13     14     [self presentViewController:ipc animated:YES completion:^{15         16     }];17 }18 19 20 //開啟本地相簿21 -(void)localPhoto22 {23     UIImagePickerController *picker = [[UIImagePickerController alloc]init];24     picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;25     picker.delegate = self;26     picker.allowsEditing = YES;27     [self presentViewController:picker animated:YES completion:^{28         29     }];30     31 }32 33 #pragma mark - UIImagePickerController協議方法34 -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info35 {36     37     UIImage *chooesImage = [info objectForKey:UIImagePickerControllerEditedImage];38     NSLog(@"%f,%f",chooesImage.size.width,chooesImage.size.height);39     40    //儲存到相簿41     if(picker.sourceType==UIImagePickerControllerSourceTypeCamera)42     {43         UIImageWriteToSavedPhotosAlbum(chooesImage,nil,nil,nil);44     }45     _photoView.image  =  chooesImage;46     NSLog(@"%f,%f",_photoView.image.size.width,_photoView.image.size.height);47     [self dismissViewControllerAnimated:YES completion:nil];48 }  49     50 //上傳頭像51 -(void)upDataUserIcon:(UIImage *)userIcon52 {53     //請求資料54     NSData *iconData = UIImageJPEGRepresentation(userIcon, 0.005f);55     NSMutableDictionary *mDict = [[NSMutableDictionary alloc]init];56     [mDict setValue:iconData forKey:@"avatar"];57 58     [SVProgressHUD showWithStatus:@"正在上傳..."];59 60     [Networking post:[NSString stringWithFormat:@"asdf"] params: mDict success:^(id responseObject) {61         62     } failure:^(NSError *error) {63         NSLog(@".......");64     }];65 }66     67     68     69     70     

 

拍照-相簿-儲存照片-上傳照片=流程

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.