zoukankan      html  css  js  c++  java
  • 最基本的添加头像

    @interface PTABabyEditBaseVC ()<UIImagePickerControllerDelegate,UIActionSheetDelegate>
    
    @property (nonatomic) UIImagePickerController *imagePickerController;
    
    @end
    
    @implementation PTABabyEditBaseVC
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
       .......
        
        _headBtn = [[UIButton alloc]initWithFrame:CGRectMake((WIDTH(self.view)-85)/2.0, (HEIGHT(headView)-85)/2.0, 85, 85)];
        [_headBtn.layer setMasksToBounds:YES];
        [_headBtn.layer setCornerRadius:WIDTH(_headBtn)/2.0];
        [_headBtn setBackgroundColor:[UIColor grayColor]];
        [_headBtn addTarget:self action:@selector(toShowCamera) forControlEvents:UIControlEventTouchUpInside];
        [_headBtn setImage:[UIImage imageNamed:@"loginIcon.png"] forState:UIControlStateNormal];
        [headView addSubview:_headBtn];
        
         ........
    }
    
    /**
     *  底部弹框
     */
    - (void)toShowCamera{
        
        UIActionSheet * actionsheet = [[UIActionSheet alloc] initWithTitle:nil
                                                                  delegate:self
                                                         cancelButtonTitle:@"取消"
                                                    destructiveButtonTitle:nil
                                                         otherButtonTitles: @"从相册选取",@"拍照", nil];
        [actionsheet showInView:self.view];
    }
    
    #pragma mark --
    #pragma mark -- UIActionSheetDelegate
    - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
        
        if(buttonIndex==0){
            [self showImagePickerForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
        }else if(buttonIndex==1){
            UIImagePickerController *   imagePicker = [[UIImagePickerController alloc] init];
            imagePicker.delegate = self;
            imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
            imagePicker.allowsEditing = NO;
            [self presentViewController:imagePicker animated:YES completion:nil];
            
        }
        
    }
    
    - (void)showImagePickerForSourceType:(UIImagePickerControllerSourceType)sourceType
    {
        UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
        imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
        imagePickerController.sourceType = sourceType;
        imagePickerController.delegate = self;
        
        self.imagePickerController = imagePickerController;
        [self presentViewController:self.imagePickerController animated:YES completion:nil];
    }
    
    
    
    #pragma mark --
    #pragma mark -- UIImagePickerControllerDelegate
    -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
        
        if ([[info objectForKey:UIImagePickerControllerMediaType] isEqualToString:(NSString*)kUTTypeImage]) {
            UIImage* image = [info objectForKey:UIImagePickerControllerOriginalImage];
            
            [_headBtn setImage:image forState:UIControlStateNormal];
        }
        [picker dismissViewControllerAnimated:YES completion:nil];
    }
  • 相关阅读:
    CHtmlEditCtrl (3): More HTML Editor Options
    CHtmlEditCtrl (2): Add a Source Text Editor to Your HTML Editor
    CHtmlEditCtrl(1) : Use CHtmlEditCtrl to Create a Simple HTML Editor
    HttpWebRequest抓取网页数据返回异常:远程服务器返回错误: (503) 服务器不可用
    HttpWebRequest: Remote server returns error 503 Server Unavailable
    所有的图片后缀名
    system函数的应用一例
    esUtil.h中的m变量报错
    IIS通过HTML5实现应用程序缓存的离线浏览
    鼠标悬浮在img上让图片变大
  • 原文地址:https://www.cnblogs.com/allanliu/p/4482202.html
Copyright © 2011-2022 走看看