如何添加“上传”按钮在 iPhone 上使用相机时?
我有一个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 应用程序) 顺便说一下,当我点击使用时,它会返回到表格视图,但是图像在哪里?它保存在选择器中吗?
I have a tableView, and I want to take a picture when clicking in one of the cells and upload it to a certain server.
I have managed to do this so far:
- (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];
}
It starts the camera and takes the picture, but I would like to get an "Upload" button when clicking in "use", can you help me? is it posible? (like the facebook app)
By the way, whe I click in use it comes back to the table view, but where is the image? is it saved in picker?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在图像选择器控制器的委托方法中获取图像
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editInfo:(NSDictionary *)editInfo
{
//在这里编写代码以将图像保存在您的 UIImage 对象中,例如:-
UIImage *myImage = img;
// 从这里添加上传按钮,或者如果您之前创建了上传按钮并将 ti 设置为隐藏,则将其隐藏属性设置为 false
}
you get your image in the delegate method of image picker controller
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo
{
//write your code here to save image in ur UIImage object for e.g:-
UIImage *myImage = img;
// add upload button from here or else set it hidden property to false if u have previously created upload button and had set ti to hidden
}
也许我没有很好地解释自己,但这是我试图做的一个示例(通过添加上传按钮自定义相机的外观): http://developer.apple.com/library/ios /#samplecode/PhotoPicker/Introduction/Intro.html%23//apple_ref/doc/uid/DTS40010196-Intro-DontLinkElementID_2
谢谢。
Maybe I didn't explain myself very good, but here is an example of what I was trying to do ( customize the look of the camera by adding an upload button): http://developer.apple.com/library/ios/#samplecode/PhotoPicker/Introduction/Intro.html%23//apple_ref/doc/uid/DTS40010196-Intro-DontLinkElementID_2
Thank you.