
//判断是否可以打开照相机
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
//摄像头
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self.navcontroller pushviewcontroller:rootview animated:yes]。 [self.navigationcontroller pushviewcontroller:thirdviewcontroller animated:yes]。 [self.navigationcontroller pushviewcontroller:secondvc animated:yes]。
}
else
{
NSLog(@"没有");

}
}
/**
* 打开相册
*/
-(void)openPhotoLibrary
{
// Supported orientations has no common orientation with the applicationios 调相机和相册,and [PUUIAlbumListViewController shouldAutorotate] is returning YES
// 进入相册
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])

{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc]init];
imagePicker.allowsEditing = YES;
elcimagepickercontroller 一个仿系统的imagepicker 但支持多选。sourcetype=weixin&from=timeline&wm=2468_1001&isappinstalled=1。sourcetype=qq&。
imagePicker.delegate = self;
[self presentViewController:imagePicker animated:YES completion:^{
NSLog(@"打开相册");
}];
}
else

{
NSLog(@"不能打开相册");
}
}
#pragma mark - UIImagePickerControllerDelegate
// 拍照完成回调
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(nullable NSDictionary<NSString *ios 调相机和相册,id> *)editingInfo NS_DEPRECATED_IOS(2_0, 3_0)
{
NSLog(@"finish..");
if(picker.sourceType == UIImagePickerControllerSourceTypeCamera)

{
//图片存入相册
for the purposes of an example, let's start building the jpa domain modelfor a digital image storage system. for the sake of simplicity, we'll startwith a simple entity "image". an image has an id, image type, file name, and image data. our system has arequirement that the image type must be specified and the image file namemust include a valid jpeg or gif extension. the code below shows theannotated image entity with some built-in bean validation constraintsapplied.。 data = [nsbitmapimagerep representationofimagerepsinarray:image.representations usingtype: nsjpegfiletype properties:nil]。 // if the imagedata is nil (i.e. if trying to save a uiimage directly or the image was transformed on download)。
}
[self dismissViewControllerAnimated:YES completion:nil];
}
//进入拍摄页面点击取消按钮
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:YES completion:nil];
}
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/ruanjian/article-113185-1.html
人家是公民