zoukankan      html  css  js  c++  java
  • 图片选择(照相机/相册)

    选择图片
    1.设置代理<UIActionSheerDelegate>
    2.UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@“请选择” delegate:self
                                      cancelButtonTitle:@“取消”
                                      destructiveButtonTitle:@“照相”
                                      otherButtonTitles:@“相册”,nil];
     3.显示 [sheet showInView:self.view];
    4.actionsheet的代理
    (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{       if(buttonIndex == 2){//取消
            return;
        }
        
        UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
        
        // 设置代理
        imagePicker.delegate =self;
        
        // 设置允许编辑
        imagePicker.allowsEditing = YES;
        
        if (buttonIndex == 0) {//照相
            imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        }else{//相册
            imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        }
        
        // 显示图片选择器
        [self presentViewController:imagePicker animated:YES completion:nil];   }

    #pragma mark 图片选择器的代理

    -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{

        WCLog(@"%@",info);

        // 获取图片 设置图片

        UIImage *image = info[UIImagePickerControllerEditedImage];

        

        self.haedView.image = image;

        

        // 隐藏当前模态窗口

        [self dismissViewControllerAnimated:YES completion:nil];

        

        // 更新到服务器

        [self editProfileViewControllerDidSave];

        

       }

     
  • 相关阅读:
    【洛谷P1948】[USACO08JAN]电话线
    【洛谷P1967】[NOIP2013]货车运输
    【题解】洛谷P2926 [USACO08DEC]拍头Patting Heads
    【题解】洛谷P1495 曹冲养猪 (中国剩余定理)
    【题解】POJ1845 Sumdiv(乘法逆元+约数和)
    【题解】P1516 青蛙的约会(Exgcd)
    【数论】同余问题
    DP Cleaning Up 打扫卫生
    set+链表 【POJ Challenge】生日礼物
    并查集 [Scoi2010]游戏
  • 原文地址:https://www.cnblogs.com/zhongxuan/p/4987670.html
Copyright © 2011-2022 走看看