国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

iOSimagePicker使用方法,方便使用!三步輕松搞定!

2019-11-14 18:01:42
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

自己總結(jié)的修改頭像的方法,只為方便自己查詢使用!轉(zhuǎn)發(fā)

步驟:1、遵守代理協(xié)議

<UIImagePickerControllerDelegate,UINavigationControllerDelegate,UIActionSheetDelegate>

2、點(diǎn)擊事件{

 

    UIActionSheet *choosePhotoActionSheet;

    

    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {

        choosePhotoActionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"選取圖片", @"")

                                                             delegate:self

                                                    cancelButtonTitle:NSLocalizedString(@"取消", @"")

                                               destructiveButtonTitle:nil

                                                    otherButtonTitles:NSLocalizedString(@"相機(jī)", @""), NSLocalizedString(@"相冊(cè)", @""), nil];

    } else {

        choosePhotoActionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"選取圖片", @"")

                                                             delegate:self

                                                    cancelButtonTitle:NSLocalizedString(@"取消", @"")

                                               destructiveButtonTitle

                                                                     :nil

                                                    otherButtonTitles:NSLocalizedString(@"相冊(cè)", @""), nil];

    }

    

    [choosePhotoActionSheet showInView:self.view];

 

}

3、實(shí)現(xiàn)代理方法

#PRagma mark - UIActionSheetDelegate

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex

{

    NSUInteger sourceType = 0;

    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {

        switch (buttonIndex) {

            case 0:

                sourceType = UIImagePickerControllerSourceTypeCamera;

                break;

            case 1:

                sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

                break;

            case 2:

                return;

        }

    } else {

        if (buttonIndex == 1) {

            return;

        } else {

            sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

        }

    }

    

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

    imagePickerController.delegate = self;

    imagePickerController.allowsEditing = YES;

    imagePickerController.sourceType = sourceType;

    [self presentViewController:imagePickerController animated:YES completion:^{

        

    }];

}

 

#pragma mark - UIImagePickerControllerDelegate

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

{

    [self dismissViewControllerAnimated:YES completion:^{

        

    }];

    self.tmpHeaderImg = [info objectForKey:UIImagePickerControllerEditedImage];

    [self.imageViewUserHead setImage:self.tmpHeaderImg];

    [self uploadImage];

}

 

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker

{

    [self dismissViewControllerAnimated:YES completion:^{

        

    }];

}

 


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 伊金霍洛旗| 开江县| 开阳县| 西安市| 军事| 沅江市| 贡觉县| 楚雄市| 黄浦区| 南木林县| 容城县| 虎林市| 漳平市| 普宁市| 长垣县| 广州市| 平阴县| 四子王旗| 辽阳市| 青龙| 辰溪县| 永康市| 乌鲁木齐县| 济源市| 石柱| 正蓝旗| 新乡县| 建阳市| 儋州市| 宣威市| 临夏市| 蓝田县| 佛学| 承德市| 平陆县| 甘德县| 开封市| 惠水县| 车险| 延庆县| 石林|