91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

在IOS中怎么拿到自己相冊中得圖片

發布時間:2020-08-06 11:54:20 來源:網絡 閱讀:785 作者:ljl5125 欄目:移動開發


//說明:法1:獲取本地相冊圖片  2:攝像頭拍照設為圖片

//步驟:一、聲明代理<UIImagePickerControllerDelegate,UINavigationControllerDelegate>

//二、聲明兩個私有的button 一個 UIImageView 分別為:1、獲取手機本地相冊圖片btnLocalLibrary  2、獲取拍照圖片btnCamera  3 p_w_picpathHead

//三、對聲明的控件初始化

//四、實現兩個GetLocalPhoto.m里面的三個函數 1-(void)btnSelect1   2-(void)btnSelect2   3-(void)p_w_picpathPickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info



@property (nonatomic, strong)UIButton *btnLocalLibrary;

@property (nonatomic, strong)UIButton *btnCamera;

@property (nonatomic, strong)UIImageView *p_w_picpathHead;




- (void)viewDidLoad

{

    [super viewDidLoad];

    // Do any additional setup after loading the view.

    

    //拿到手機相機,拍照

    self.btnCamera = [UIButton buttonWithType:UIButtonTypeCustom];

    [self.btnCamera setImage:[UIImage p_w_picpathNamed:@"head.jpg"] forState:UIControlStateNormal];

    self.btnCamera.center = CGPointMake(self.view.center.x*1.5, self.view.center.y*1.7);

    self.btnCamera.bounds = CGRectMake(0, 0, 70, 70);

    self.btnCamera.layer.cornerRadius = 35;

    self.btnCamera.layer.borderColor = [UIColor whiteColor].CGColor;

    self.btnCamera.layer.borderWidth = 3.0;

    self.btnCamera.clipsToBounds = YES;

    [self.btnCamera addTarget:self action:@selector(btnSelect1) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:self.btnCamera];

    

    

    //從相冊中獲取頭像

    self.btnLocalLibrary = [UIButton buttonWithType:UIButtonTypeCustom];

    [self.btnLocalLibrary setImage:[UIImage p_w_picpathNamed:@"head.jpg"] forState:UIControlStateNormal];

    self.btnLocalLibrary.center = CGPointMake(self.view.center.x*0.5, self.view.center.y*1.7);

    self.btnLocalLibrary.bounds = CGRectMake(0, 0, 70, 70);

    self.btnLocalLibrary.layer.cornerRadius = 35;

    self.btnLocalLibrary.layer.borderColor = [UIColor whiteColor].CGColor;

    self.btnLocalLibrary.layer.borderWidth = 3.0;

    self.btnLocalLibrary.clipsToBounds = YES;

    [self.btnLocalLibrary addTarget:self action:@selector(btnSelect2) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:self.btnLocalLibrary];


    

    

    //頭像

    self.p_w_picpathHead = [[UIImageView alloc]initWithFrame:CGRectMake(130, 100, 60, 60)];

    self.p_w_picpathHead.p_w_picpath = [UIImage p_w_picpathNamed:@"head.jpg"];

    [self.view addSubview:self.p_w_picpathHead];

    

}



#pragma mark -攝像頭拍照的圖片

-(void)btnSelect1

{

    //判斷是否可以使用攝像頭

    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])

    {

        //打開攝像頭

        UIImagePickerController * picker = [[UIImagePickerController alloc]init];

        picker.delegate = self;

        picker.sourceType = UIImagePickerControllerSourceTypeCamera;

        [self presentViewController:picker animated:YES completion:nil];

    }

    else

    {

        UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:@"不能使用照相機" delegate:self cancelButtonTitle:@"確定" otherButtonTitles:nil, nil];

        

        [alert show];

        

    }

  

}



#pragma mark -拿已經存在手機相冊里的圖片

-(void)btnSelect2

{

//    UIImagePickerController 

    //判斷是否可以使用相冊

    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {

        UIImagePickerController * picker = [[UIImagePickerController alloc]init];

        picker.delegate = self;

        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

        

        [self presentViewController:picker  animated:YES completion:nil];

    }else

    {

        UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:@"不能使用相冊" delegate:self cancelButtonTitle:@"確定" otherButtonTitles:nil, nil];

        

        [alert show];

    }

    

}


-(void)p_w_picpathPickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

{

    //將照片顯示在屏幕上

    //獲取當前拍攝的照片

    UIImage * p_w_picpath = [info valueForKey:UIImagePickerControllerOriginalImage];

    self.p_w_picpathHead.p_w_picpath = p_w_picpath;

    UIImage * p_w_picpath2 = [info valueForKey:UIImagePickerControllerOriginalImage];

    self.p_w_picpathHead.p_w_picpath = p_w_picpath2;

    //將照片存放到相冊當中

    if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {

        UIImageWriteToSavedPhotosAlbum(p_w_picpath, p_w_picpath2,nil, nil);

    }

    [self dismissViewControllerAnimated:YES completion:nil];

}


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

那坡县| 云安县| 汝南县| 凤翔县| 汶川县| 东城区| 东港市| 海林市| 宝丰县| 亳州市| 奉新县| 台州市| 华安县| 中阳县| 子长县| 涪陵区| 平原县| 盐城市| 沧源| 广昌县| 博客| 封开县| 澎湖县| 洛宁县| 浦北县| 隆化县| 淳安县| 博爱县| 洛南县| 武强县| 都安| 临汾市| 循化| 巩留县| 洛川县| 崇阳县| 沂源县| 怀远县| 土默特右旗| 涞源县| 墨竹工卡县|