首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Iphone >

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

2012-04-21 
新手求教camera程序解读求教各位高手,这段代码是做什么用的,拜托大概加点注释,比如是做什么用的,用什么类

新手求教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下吧

热点排行