真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

在IOS中怎么拿到自己相冊中得圖片-創(chuàng)新互聯(lián)

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

丹鳳ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:028-86922220(備注:SSL證書合作)期待與您的合作!

//步驟:一、聲明代理

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

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

//四、實現(xiàn)兩個GetLocalPhoto.m里面的三個函數(shù) 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.

  //拿到手機(jī)相機(jī),拍照

  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:@"不能使用照相機(jī)" delegate:self cancelButtonTitle:@"確定" otherButtonTitles:nil, nil];

    [alert show];

  }

}

#pragma mark -拿已經(jīng)存在手機(jī)相冊里的圖片

-(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

{

  //將照片顯示在屏幕上

  //獲取當(dāng)前拍攝的照片

  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;

  //將照片存放到相冊當(dāng)中

  if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {

    UIImageWriteToSavedPhotosAlbum(p_w_picpath, p_w_picpath2,nil, nil);

  }

  [self dismissViewControllerAnimated:YES completion:nil];

}

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。


網(wǎng)站欄目:在IOS中怎么拿到自己相冊中得圖片-創(chuàng)新互聯(lián)
地址分享:http://weahome.cn/article/dojjog.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部