IOS获取系统相册中照片的示例代码
程序员文章站
2023-12-17 18:48:40
先来看看效果图
下面话不多少,我们直接上代码:
#import "viewcontroller.h"
@interface viewcontrolle...
先来看看效果图
下面话不多少,我们直接上代码:
#import "viewcontroller.h" @interface viewcontroller ()<uinavigationcontrollerdelegate,uiimagepickercontrollerdelegate> @property (weak, nonatomic) iboutlet uiimageview *iconview; @end @implementation viewcontroller - (ibaction)chooseimage { //弹出系统相册 uiimagepickercontroller *pickvc = [[uiimagepickercontroller alloc] init]; //设置照片来源 pickvc.sourcetype = uiimagepickercontrollersourcetypesavedphotosalbum; pickvc.delegate = self; [self presentviewcontroller:pickvc animated:yes completion:nil]; } #pragma mark - uiimagepickercontrollerdelegate -(void)imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary<nsstring *,id> *)info{ uiimage *photo = info[uiimagepickercontrolleroriginalimage]; uiimageview *imagev = [[uiimageview alloc] init]; imagev.frame = self.iconview.frame; imagev.image = photo; imagev.userinteractionenabled = yes; [self.view addsubview:imagev]; [self dismissviewcontrolleranimated:yes completion:nil]; } @end
总结
以上就是ios如何获取系统相册照片的示例代码,有需要的朋友们可以直接用,对大家的开发还是很有帮助的,如果大家有疑问可以留言交流。