IOS调用相机相册
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了IOS调用相机相册,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2129字,纯文字阅读大概需要4分钟。
内容图文
![IOS调用相机相册](/upload/InfoBanner/zyjiaocheng/1333/b5de6969f9734b15b2125bbf7ffea605.jpg)
- #import "SendViewController.h" //只能打开,没有加载图片的代码,老代码,供参考
- #import <MobileCoreServices/UTCoreTypes.h>
- @interface SendViewController ()<UIActionSheetDelegate,UINavigationControllerDelegate,UIImagePickerControllerDelegate>
- -(IBAction)selectDescPic:(id)sender;
- @end
- @implementation SendViewController
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- }
- return self;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- -(IBAction)selectDescPic:(id)sender {
- UIActionSheet *actionSheet = [[UIActionSheet alloc]
- initWithTitle:nil
- delegate:self
- cancelButtonTitle:@"取消"
- destructiveButtonTitle:nil
- otherButtonTitles:@"拍照", @"从手机相册选择",nil];
- actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
- [actionSheet showInView:self.view];
- }
- -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
- if (buttonIndex == 0) {
- UIImagePickerController *camera = [[UIImagePickerController alloc] init];
- camera.delegate = self;
- camera.allowsEditing = NO;
- if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
- camera.sourceType = UIImagePickerControllerSourceTypeCamera;
- //此处设置只能使用相机,禁止使用视频功能
- camera.mediaTypes = [[NSArray alloc]initWithObjects:(NSString *)kUTTypeImage,nil];
- } else {
- NSLog(@"相机功能不可用");
- return;
- }
- [self presentViewController:camera animated:YES completion:nil];
- } else if (buttonIndex == 1) {
- UIImagePickerController *picker = [[UIImagePickerController alloc] init];
- picker.delegate = self;
- picker.allowsEditing = NO;
- //从相册列表选取
- picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
- if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
- //此处设置只能使用相机,禁止使用视频功能
- picker.mediaTypes = [[NSArray alloc]initWithObjects:(NSString *)kUTTypeImage,nil];
- }
- [self presentViewController:picker animated:YES completion:nil];
- } else if(buttonIndex == 2) {
- //取消
- }
- }
- @end
原文:http://www.cnblogs.com/isItOk/p/4873100.html
内容总结
以上是互联网集市为您收集整理的IOS调用相机相册全部内容,希望文章能够帮你解决IOS调用相机相册所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。