我如何构建一个首先在空白UIView中的应用程序,然后允许用户使用相机拍照,然后该图片将出现在用户可以拖动和移动图像的UiView上。
这是我到目前为止的代码,
-(IBAction) getPhoto:(id) sender {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
if((UIButton *) sender == choosePhotoBtn) {
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
} else {
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
savebutton.hidden=NO;
}
[self presentModalViewController:picker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];
imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
}
-(void)imageSavedToPhotosAlbum:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
NSString *message; NSString *title;
if (!error) {
title = NSLocalizedString(@"Image Saved Successfully!", @"");
message = NSLocalizedString(@"Tap Library and select this image.", @"");
}
else { title = NSLocalizedString(@"SaveFailedTitle", @""); message = [error description];
} UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title
message:message delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK", @"") otherButtonTitles:nil];
[alert show]; [alert release];
[message release]; [title release];}
-(IBAction) saveImage:(id)sender{
UIImage *img = imageView.image;
UIImageWriteToSavedPhotosAlbum(img, self, @selector(imageSavedToPhotosAlbum: didFinishSavingWithError: contextInfo:), nil);
}
还有关于Xcode中照片修改的好教程吗?
非常感谢。