如何在Iphone中使用相机时添加“上传”按钮?

时间:2010-12-17 12:32:41

标签: iphone xcode camera uiimagepickercontroller

我有一个tableView,我想点击其中一个单元格并将其上传到某个服务器时拍照。 到目前为止,我已设法做到这一点:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {


//do actions
UIImagePickerController *picker = [[UIImagePickerController alloc] init];

// Set the image picker source to the camera:
picker.sourceType = UIImagePickerControllerSourceTypeCamera;

// Hide the camera controls:
picker.showsCameraControls = YES;
picker.navigationBarHidden = NO;

// Make the view full screen:
picker.wantsFullScreenLayout = YES;
//picker.cameraViewTransform = CGAffineTransformScale(picker.cameraViewTransform, CAMERA_TRANSFORM_X, CAMERA_TRANSFORM_Y);

// Now insert our overlay view (it has to be here cuz it's a modal view):
//picker.cameraOverlayView = overlayView;

matches *aMatch = [appDelegate.matches objectAtIndex:indexPath.row];
NSLog(@"%@", [NSString stringWithFormat:@"%d", aMatch.match_id]);

// Show the picker:
[self presentModalViewController:picker animated:YES];


[picker release];

}

它启动相机并拍照,但我想在点击“使用”时获得“上传”按钮,你能帮帮我吗?它可以吗? (比如facebook应用) 顺便说一句,当我点击使用它回到表格视图,但图像在哪里?是保存在选择器中吗?

2 个答案:

答案 0 :(得分:1)

您可以在图像选择器控制器的委托方法中获取图像 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo
{
//在这里编写你的代码以保存你的UIImage对象中的图像,例如: -
UIImage * myImage = img;
//从这里添加上传按钮,或者如果您之前已创建上传按钮并将ti设置为隐藏,则将其隐藏属性设置为false }

答案 1 :(得分:0)

也许我没有解释自己非常好,但这里是我尝试做的一个例子(通过添加上传按钮来自定义相机的外观):http://developer.apple.com/library/ios/#samplecode/PhotoPicker/Introduction/Intro.html%23//apple_ref/doc/uid/DTS40010196-Intro-DontLinkElementID_2 谢谢。