【问题标题】:Iphone: Appear and allow user interactions on the UIImage [closed]Iphone:出现并允许 UIImage 上的用户交互 [关闭]
【发布时间】:2011-12-19 09:22:31
【问题描述】:

我如何构建一个应用程序,首先在空白 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中照片修改的好教程?

非常感谢。

【问题讨论】:

  • 您不认为您是在要求从同一个问题构建整个应用程序吗?尝试先实现一些东西。
  • 我已经编辑了问题。我只知道如何启动相机并将其放置在 UIImage 上,但我不知道如何拖动这张图片。非常感谢

标签: iphone camera uiimage


【解决方案1】:

借助 uitouchmoved 类,您可以轻松地在 uiview 中移动图像。参见this

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多