我在我的应用程序中使用UIImagePickerController.有没有人使用任何优化技巧来拍照延迟?我不需要将它们存储到库中.我只想捕获像素数据并在进行计算后销毁图像对象.
此外,还有一种方法可以在镜头加载时隐藏它吗?
(最坏的情况是,我可以在相机启动时屏蔽镜头并在保存/计算时屏蔽冻结的图像.)
编辑: 我已经设置好了showsCameraControls = NO;.这会隐藏快照之间的镜头效果,但不会影响相机启动时镜头动画的存在.
我正在使用UIImagePickerController将照片中的图片设置为UIImageView.然而,在UIImageView中,图像会自动缩放,因为我在IB中提到了"缩放以适应".我想以80x80像素的分辨率保存我选择的图像,这样我就不必进行缩放.(由于这个扩展问题,我的应用程序变得非常缓慢.)
这是我的代码中的一个snippit:
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage : (UIImage *)image
editingInfo:(NSDictionary *)editingInfo
{
[picker dismissModalViewControllerAnimated:YES];
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
photoView.image = image;
NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *pngFilePath = [NSString stringWithFormat:@"%@/foto1.png",docDir];
NSData *data = [NSData dataWithData:UIImagePNGRepresentation(image)];
[data writeToFile:pngFilePath atomically:YES];
}
Run Code Online (Sandbox Code Playgroud)
非常感谢帮助!
我正在尝试使用UIImagePickerController从他们的iPhone/iPad上的用户照片中获取照片.这段代码适用于iPhone,但是当我在iPad上运行时,调试器给我的消息是" 由于未捕获的异常终止应用程序'NSInvalidArgumentException',原因:'在iPad上,必须通过UIPopoverController呈现UIImagePickerController'".我是Objective-C的新手,所以我不确定如何编辑这个代码,以便在iPad上运行时使用UIPopoverController.我宁愿不创建2个新的视图控制器,所以我想知道是否有人知道我需要添加什么代码才能让它在iPhone和iPad上运行.这是我的视图控制器中的代码:
ViewController.h:
@interface PhotoViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate> {
UIButton *grabButton;
UIImageView *image;
UIImagePickerController *imgPicker;
}
@property (strong, nonatomic) IBOutlet UIButton *grabButton;
@property (strong, nonatomic) IBOutlet UIImageView *image;
@property (strong, nonatomic) UIImagePickerController *imgPicker;
- (IBAction)grabImage;
@end
Run Code Online (Sandbox Code Playgroud)
ViewController.m:
#import "PhotoViewController.h"
@implementation PhotoViewController
@synthesize grabButton;
@synthesize image;
@synthesize imgPicker;
- (IBAction)grabImage {
[self presentModalViewController:self.imgPicker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {
image.image = img;
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super …Run Code Online (Sandbox Code Playgroud) 我正在尝试保存用户使用相机拍摄的图像
1)如果我使用UIImageWriteToSavedPhotosAlbum我似乎无法分配我想要的fileName.怎么样,你能选择文件名吗?
使用此选项的好处是
[picker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
然后给出照片库目录的缩略图库.
2)它引导我到我的下一个问题可以
[picker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
用来从你自己的个人目录中获取图像?
3)无论如何以编程方式在照片库中创建子文件夹
4)最后,
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSPicturesDirectory, NSUserDomainMask, YES);
if (![[NSFileManager defaultManager] fileExistsAtPath:[paths objectAtIndex:0] isDirectory:&isDir]) {
NSError *error;
[[NSFileManager defaultManager] createDirectoryAtPath:[paths objectAtIndex:0 withIntermediateDirectories:YES attributes:nil error:&error];
}
Run Code Online (Sandbox Code Playgroud)
检查NSPicturesDirectory是否存在以便我可以写入它我不断收到Cocoa错误513
提前致谢
嗨,我正在开发一个应用程序,其中有一个选项从iOS照片库中选择照片.我必须将选定的照片上传到服务器.要上传图像我正在使用Kaltura SDK,所以我处于无法直接发送UIImage到服务器的情况.我需要发送保存的图像文件路径.
为此,我找到了一个解决方案,即将选定的照片保存在特定的文件路径中,然后我将使用该文件路径.但问题是我不希望再次在手机内存中保存照片,因为这些照片已经存储在特定路径中.
那么有没有其他选项来重新保存图像文件路径而不再保存它?
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.allowsEditing = YES;
[self presentViewController:imagePicker animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
此代码使ios7设备上的EXC_BAD_ACCESS崩溃.在iOS6上 - 一切正常,UIImagePickerControllerSourceTypePhotoLibrary工作正常.
我的Iphone应用程序使用相机,我有以下代码:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = NO;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
[self presentViewController:picker animated:YES completion:NULL];
Run Code Online (Sandbox Code Playgroud)
我希望相机应用程序不会打开,相反我会在我自己的uiview中使用相机,或者uiimageview可以吗?
我尝试过这行代码而不是 [self presentViewController:picker animated:YES completion:NULL];:
[self.view addSubview:picker];
Run Code Online (Sandbox Code Playgroud)
这会导致异常 [UIImagePickerController superview]: unrecognized selector sent to instance
解决方案: 我找到了这个很棒的教程,包括代码示例和下载项目
我正在尝试自定义我UIImagePickerController的状态栏外观.我有一个自定义图像我用于后退按钮,它正确显示,但我想要做的是删除文本(所以它只是图像).我经常在我的应用程序中执行此操作,但我似乎无法在其中使用它UIImagePickerController.
我想我可以做点什么......
UIImagePickerController *uiipc = [[UIImagePickerController alloc]init];
uiipc.navigationController.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
Run Code Online (Sandbox Code Playgroud)
然而,这似乎不起作用,当选择文件夹,例如"照片"时,我仍然可以获得自定义图像,旁边的文本"照片"为后退按钮.
有人可以帮我删除文字吗?
编辑:值得注意的是自定义图像是在我的应用程序委托中设置的,这就是为什么你在我的例子中没有看到它.
cocoa-touch objective-c uiimagepickercontroller uinavigationcontroller ios
想要添加在数组中添加的摄像头捕获图像并在集合视图中加载该数组显示所有图像
///here i get the capture image in picker
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.delegate = self;
imagePicker.allowsEditing = YES;
[self presentViewController:imagePicker animated:YES completion:nil];
}
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// in this part how can add the camera capture image in array
// and load that array value in collection view..
}
Run Code Online (Sandbox Code Playgroud)
帮助我如何实现这一目标......
我有两个UIImageViews我要加载两个不同的图像.我有两个按钮触发a UIImagePickerController并调用我的
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
Run Code Online (Sandbox Code Playgroud)
方法.
有没有办法区分上面的方法被称为哪个选择器?
ios ×6
iphone ×6
objective-c ×5
camera ×1
cocoa-touch ×1
ios5 ×1
ios7 ×1
optimization ×1
picker ×1
scale ×1
uiimage ×1
uiimageview ×1
xcode ×1