国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 靖远县| 庆阳市| 巨鹿县| 岐山县| 桐乡市| 祁连县| 镇远县| 老河口市| 台山市| 临邑县| 宿州市| 阳春市| 津市市| 阿瓦提县| 昌平区| 淳安县| 石景山区| 平果县| 商水县| 德昌县| 吉木乃县| 东港市| 湖州市| 平罗县| 永定县| 上蔡县| 海伦市| 昭苏县| 红原县| 南丰县| 永丰县| 阿城市| 通江县| 梨树县| 平顺县| 厦门市| 慈利县| 江西省| 育儿| 怀仁县| 汾西县|