您好,登錄后才能下訂單哦!
1 用途: 是系統(tǒng)提供的用來獲取圖片和視頻的接口;
2獲取圖片途徑:拍照,圖庫,相冊獲取
enum {
UIImagePickerControllerSourceTypePhotoLibrary ,
//來自圖庫
UIImagePickerControllerSourceTypeCamera ,
//來自相機
UIImagePickerControllerSourceTypeSavedPhotosAlbum
//來自相冊
};
3 步驟:
初始化一個UIImagePickerController類
設(shè)置數(shù)據(jù)來源類型,—— 上面2
設(shè)置代理
如果需要對圖片進行修改,allowsEditing = yes
4 具體代碼實現(xiàn)
#pragma mark 選擇圖片
- (IBAction)selectImage:(UITapGestureRecognizer *)sender{
//圖片選擇控制器
UIImagePickerController *pickerController=[[UIImagePickerController alloc] init];
//選擇你要使用的類型 圖集,相冊,相機 pickerController.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
pickerController.delegate=self;
pickerController.allowsEditing=YES;
[self presentViewController:pickerController animated:YES completion:nil];
}
#pragma mark delegate
-(void)p_w_picpathPickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
//根據(jù)選擇的圖片 設(shè)置頭像
_IconImage.p_w_picpath=info[@"UIImagePickerControllerOriginalImage"];
[picker dismissViewControllerAnimated:YES completion:^{
}];
}
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。