当前位置: 代码迷 >> Iphone >> 新手求教camera程序解读解决方案
  详细解决方案

新手求教camera程序解读解决方案

热度:151   发布时间:2016-04-25 06:48:23.0
新手求教camera程序解读
求教各位高手,这段代码是做什么用的,拜托大概加点注释,
比如是做什么用的,用什么类什么方法,选到的文件保存在哪里 这样的,小弟拜谢了!!
#import "CameraViewController.h"

@implementation CameraViewController
@synthesize imageView;
@synthesize takePictureButton;
@synthesize selectFromCameraRollButton;

- (void)viewDidLoad {
  if (![UIImagePickerController isSourceTypeAvailable:
  UIImagePickerControllerSourceTypeCamera]) {
  takePictureButton.hidden = YES;
  selectFromCameraRollButton.hidden = YES;
  }
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
  self.imageView = nil;
  self.takePictureButton = nil;
  self.selectFromCameraRollButton = nil;
  [super viewDidUnload];
}
- (void)dealloc {
  [imageView release];
  [takePictureButton release];
  [selectFromCameraRollButton release];
  [super dealloc];
}
#pragma mark -
- (IBAction)getCameraPicture:(id)sender {
  UIImagePickerController *picker =
  [[UIImagePickerController alloc] init];
  picker.delegate = self;
  picker.allowsImageEditing = YES;
  picker.sourceType = (sender == takePictureButton) ? 
  UIImagePickerControllerSourceTypeCamera :
  UIImagePickerControllerSourceTypeSavedPhotosAlbum;
  [self presentModalViewController:picker animated:YES];
  [picker release];
   
}
- (IBAction)selectExistingPicture {
  if ([UIImagePickerController isSourceTypeAvailable:
  UIImagePickerControllerSourceTypePhotoLibrary]) {
  UIImagePickerController *picker =
  [[UIImagePickerController alloc] init];
  picker.delegate = self;
  picker.allowsImageEditing = YES;
  picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  [self presentModalViewController:picker animated:YES];
  [picker release];
  }
  else {
  UIAlertView *alert = [[UIAlertView alloc] 
  initWithTitle:@"Error accessing photo library" 
  message:@"Device does not support a photo library" 
  delegate:nil 
  cancelButtonTitle:@"Drat!" 
  otherButtonTitles:nil];
  [alert show];
  [alert release];
  }
}
#pragma mark -
- (void)imagePickerController:(UIImagePickerController *)picker 
  didFinishPickingImage:(UIImage *)image
  editingInfo:(NSDictionary *)editingInfo {
  imageView.image = image;
  [picker dismissModalViewControllerAnimated:YES];
   
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
   
  [picker dismissModalViewControllerAnimated:YES];
}
@end


------解决方案--------------------
建议楼主直接编译运行,然后哪行不明白注释哪行,或者单步执行~~

这样必看注释有效果而且记忆深刻
------解决方案--------------------
不懂的地方,google下吧
  相关解决方案