Iphone web view during use of Camera - iphone

Is it possible to open webview during use of camera in app.if it is possible plz let me know.

You could try:
- (BOOL)startCameraPickerFromViewController:(UIViewController*)controller usingDelegate:(id<UIImagePickerControllerDelegate>)delegateObject
{
//NSLog(#"008 ::Create Postcard :: start photo camera");
if ((![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) || (delegateObject == nil) || (controller == nil)) {
return NO;
}
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.delegate = self;
UIView *overlay = [[UIView alloc]initWithFrame:CGRectMake(x, y, w, h)];
// overlay.transform = CGAffineTransformMakeRotation(M_PI / 2.0);
// overlay.backgroundColor = [UIColor redColor];
{create your webview here}
[overlay addSubview:webview];
[webview release];
[picker.cameraOverlayView = overlay;
[controller presentModalViewController:picker animated:YES];
return YES;
}
If you have enough recources on the phone it might could work i guess

Related

How to to make this image picker work on iPad?

I need help getting this code to work on iPad, it works fine on iPhone but for what ever reason not iPad.I have no idea what to do get this image picker to work on iPad. Any help will be appreciated.
-(IBAction)getCameraPicture:(id)sender
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsImageEditing = YES;
picker.sourceType = (sender == takePictureButton) ? UIImagePickerControllerSourceTypeCamera :
UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[self presentModalViewController: picker animated:YES];
[picker release];
}
-(IBAction)selectExitingPicture
{
if([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController *picker= [[UIImagePickerController alloc]init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
[picker release];
}
}
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage : (UIImage *)image
editingInfo:(NSDictionary *)editingInfo
{
imageView.image = image;
[picker dismissModalViewControllerAnimated:YES];
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *) picker
{
[picker dismissModalViewControllerAnimated:YES];
}
On iPad you need to show it inside a UIPopoverController, not present it modally.
You can display the UIImagePicker as a modalView in iPhone. But in iPad you need to use UIPopover as a container for displaying the imagePicker.
Re-write your code like:
-(IBAction)selectExitingPicture
{
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController *picker= [[UIImagePickerController alloc]init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
self.popover = [[UIPopoverController alloc]
initWithContentViewController:picker];
popover.delegate = self;
[self.popover presentPopoverFromRect:CGRectMake(0,0,170,250)
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
else
{
[self presentModalViewController:picker animated:YES];
}
[picker release];
}
In your #interface add the necessary protocols and necessary instances
#interface yourController: UIViewController
<UIImagePickerControllerDelegate,
UINavigationControllerDelegate, UIPopoverControllerDelegate>
{
UIPopoverController *popover;
}
#property (nonatomic, strong) UIPopoverController *popover;
#end
It'll work on both iPad and iPhone.
You can try this:
Change the CGRectMake for custom popover and CGSizeMake for content size.
- (IBAction)imageFromAlbum:(id)sender
{
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
// es iPad
if ([[UIDevice currentDevice]userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
//Averiguar si está en portrait o landscape
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
//PORTRAIT
if(orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
{
[self cerrarTeclado];
self.popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
self.popover.delegate = self;
[self.popover presentPopoverFromRect:CGRectMake(600, 400, 311, 350) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];
[self.popover setPopoverContentSize:CGSizeMake(330, 515)];
}
//LANDSCAPE
if (orientation == UIInterfaceOrientationLandscapeRight || orientation == UIInterfaceOrientationLandscapeLeft)
{
self.popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
self.popover.delegate = self;
[self.popover presentPopoverFromRect:CGRectMake(850, 400, 311, 350) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];
[self.popover setPopoverContentSize:CGSizeMake(330, 515)];
}
} else {
// no es iPad
[self presentViewController:imagePicker animated:YES completion:nil];
}
}

Universal Xcode Camera Roll App Issue

I have a universal app in Xcode. If the user is using an iPad the use image from library button works great. However if they use an iPhone the button doesn't work.
Here is the error I receive.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIPopoverController initWithContentViewController:] called when not running under UIUserInterfaceIdiomPad.'
Was told this code would work. Does it go into the (IBAction) Code below?
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { Add Popover code here } else {
Add alternative for popover here }
- (IBAction) useCameraRoll: (id)sender
{
if ([self.popoverController isPopoverVisible]) {
[self.popoverController dismissPopoverAnimated:YES];
} else {
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [NSArray arrayWithObjects:
(NSString *) kUTTypeImage,
nil];
imagePicker.allowsEditing = YES;
newMedia = NO;
}
}
}
This crash is occuring because you can't use UIPopOverControllers on iPhones, only on iPads.
[UIPopoverController initWithContentViewController:] called when not
running under UIUserInterfaceIdiom Pad.'
Try something like this:
- (IBAction)useCameraRoll:(id)sender
{
UIPopoverController *popoverController = [[UIPopoverController alloc] init];
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.mediaTypes = [NSArray arrayWithObjects:
(NSString *) kUTTypeImage,
nil];
imagePicker.allowsEditing = YES;
newMedia = NO;
}
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
if (popoverController.isPopoverVisible) {
[popoverController dismissPopoverAnimated:YES];
}else{
[popoverController setContentViewController:imagePicker];
[popoverController setDelegate:self];
[popoverController presentPopoverFromRect:CGRectMake(0, 0, 320, 320) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
}else{
[imagePicker presentViewController:imagePicker animated:YES completion:nil];
}
}

Display UIImagePickerViewController for uiimagepickercontrollersourcetypephotolibrary from UIActionSheet in IPad

I have a UIActionSheet which has options to choose image from Camera or photo library. For this I took imagePickerViewController. For camera it works absolutely fine. But not for photo library.
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0)
{
imgController = [[UIImagePickerController alloc] init];
imgController.allowsEditing = YES;
imgController.sourceType = UIImagePickerControllerSourceTypeCamera;
imgController.delegate=self;
[self presentModalViewController:imgController animated:YES];
}
else if (buttonIndex == 1)
{
if ([self.popoverController isPopoverVisible]) {
[self.popoverController dismissPopoverAnimated:YES];
[popoverController release];
} else {
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.allowsEditing = NO;
self.popoverController = [[UIPopoverController alloc]
initWithContentViewController:imagePicker];
self.popoverController.delegate = self;
[self.popoverController setPopoverContentSize:CGSizeMake(500, 500)];
[self.popoverController presentPopoverFromRect:self.view.frame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
[imagePicker release];
}
}
}
}
On touching photo library option a small popupViewController is created on top of view but it is very small. Why the popupViewController is too small? Is there some other way to for displaying UIImagePickerViewController for uiimagepickercontrollersourcetypephotolibrary?
Try out this example
CGRect popoverRect = [self.view convertRect:[self.view frame]
fromView:[self.view superview]];
popoverRect.size.width = MIN(popoverRect.size.width, 80) ;
popoverRect.origin.x = popoverRect.origin.x+150;
[self.popoverController
presentPopoverFromRect:popoverRect
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionLeft
animated:YES];
Try by not setting the PopoverContentSize for UIImagePickerViewController presented in the popover - I think it's taken care of automatically! Also, the CGRect in presentPopoverFromRect: seems to be incorrect as you're passing the view's frame which translates to the popover pointing roughly to the centre of the screen. You might want to set that to the frame of the button that presented the UIActionSheet!
I think that the rect you pass in should be smaller, not the size of the whole view:
CGRect popFrom = CGRectMake (CGPointMake(50,50),10,10);
[self.popoverController presentPopoverFromRect:popFrom
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
Try this:
imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:imagePickerController animated:YES];

Issue with imagePicker

I've got a little tiny problem when i present a ImagePickerController..
Here is my code:
UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
imgPicker.allowsEditing = NO;
imgPicker.delegate = self;
imgPicker.navigationBarHidden = YES;
imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:imgPicker animated:YES];
And this is what i see on my device:
We can see something which can be a navigationBar but i set it to HIDDEN and nothing change..
Anyone has an idea?

UIImagePickerController cameraOverlayView can not be full screen on the iPad

this is my code:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls = NO;
picker.allowsEditing = NO;
picker.delegate = self;
picker.navigationBarHidden = YES;
picker.toolbarHidden = YES;
picker.wantsFullScreenLayout = YES;
UIView *overlay = [[UIView alloc] initWithFrame:CGRectZero];
overlay.backgroundColor = [UIColor greenColor];
overlay.alpha = 0.3;
overlay.clipsToBounds = NO;
UIButton *takePictureButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 1024, 1024)];
[takePictureButton addTarget:self action:#selector(takePictureButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
takePictureButton.backgroundColor = [UIColor purpleColor];
[overlay addSubview:takePictureButton];
picker.cameraOverlayView = overlay;
[takePictureButton release];
[overlay release];
_currentPicker = picker;
[self presentModalViewController:picker animated:YES];
[picker release];
And it's look like on iPad 2 with iOS 4.3.2:
sorry, I can't post image
What I want is it can take picture when user tap anywhere on the screen.
Forgive my poor English.
I solved this question by myself:
just reset the size of cameraOverlayView after present UIImagePickerController.
code like this:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls = NO;
picker.allowsEditing = NO;
picker.delegate = self;
UIButton *takePictureButton = [[UIButton alloc] initWithFrame:CGRectZero];
[takePictureButton addTarget:self action:#selector(takePictureButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
picker.cameraOverlayView = takePictureButton;
[self presentModalViewController:picker animated:YES];
takePictureButton.frame = CGRectMake(0, 0, 1024, 1024);
[picker release];
[takePictureButton release];
Although it's not elegant, but it work :)