Iphone:在UIImage上显示并允许用户交互



我怎么能建立一个应用程序,首先在一个空白的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的照片修改?

许多谢谢。

在uittouchmoved类的帮助下,你可以很容易地在uiview中移动图像。看到这个。

最新更新