Access Camera in Same View - iphone

When we use UIImagePickerController to get camera action we need to open it in different viewController like as:
UIImagePickerController *imagepicker;
[self presentModalViewController:imagepicker animated:YES];
but I want to use this in same View controller from where this UIImagePickerController is called in different View.
Is it possible?

Try creating a view where you want the image picker to appear say destView.
Create the image picker and then use [destView addSubview: imagepicker.view]
You may need to play with size of destView to get things right.

Related

Customized UIImagePickerController issue when loaded a second time

I have made a UIImagePickerController with a custom overlay view in order to enhance the interface and it's working great the first time I load it, it's perfect.
The problem is that if I dismiss it and then shows it again I have a strange bug. the camera view and the overlay appear behind the NavBar and the TabBar of the previous view controller.
I have try different ways of implementing this but I can't get this bug solved.
Here is how I call my UIImagePickerController. It's inspired by this sample code.
[self.cameraOverlayViewController setupImagePicker:UIImagePickerControllerSourceTypeCamera];
[self presentModalViewController:self.cameraOverlayViewController.imagePickerController animated:YES];
Once my picture taken, I dismiss the UIImagePickerController:
[self dismissModalViewControllerAnimated:YES];
Definitly nothing special in the way of implementing it.
And here 2 screenshots:
And now taken at second launch:
At second launch http://puic.dev.madebykawet.com/IMG_0929.PNG
Thanks for your answers !
have you tried something like that?
//hide all controls
picker.showsCameraControls = NO;
picker.navigationBarHidden = YES;
picker.toolbarHidden = YES;
Thanks for your help Peko but it was not that.
After hours trying stuff, I found out that I needed to launch the UIImagePickerController from the root controller.
This is maybe because I'm using TTNavigator from the Three20 library.
So in my case to have this working:
[[TTNavigator navigator].rootViewController presentModalViewController:self.cameraOverlayViewController.imagePickerController animated:YES];
instead of:
[self presentModalViewController:self.cameraOverlayViewController.imagePickerController animated:YES];
same thing for dismissModalViewControllerAnimated:
[[TTNavigator navigator].rootViewController dismissModalViewControllerAnimated:YES];

ipad pushViewController display not as full screen

How to push an ViewController display not as full screen on iPad like the image below
Welcome any comment
Use UIViewController's modalPresentationStyle property, along with the standard presentModalViewController:animated:. Your screenshot is using UIModalPresentationFormSheet. There is also UIModalPresentationPageSheet, which displays fullscreen in portrait mode but leaves borders on either side in landscape.
The image you are showing is a type of modal view. You would display it with something like:
myViewController.modalPresentationStyle = UIModalPresentationFormSheet;
[myViewController presentModalViewController: myModalViewController animated:YES];
See the documentation on UIViewController's for more info on modal views.
We can present the modalViewController in four different way .ie
1. UIModalPresentationFullScreen
2. UIModalPresentationPageSheet
3. UIModalPresentationFormSheet
4. UIModalPresentationCurrentContext.
Here you are using third One now..
if you dont want to use these thing simply use the following code..
[self presentModalViewController Animated:YES];
From the screenshot I take it that you're doing something like this:
UIViewController* newController = LoadTheController();
newController.modalPresentationStyle = UIModalPresentationFormSheet;
[currentViewController presentModalViewController:vc animated:YES];
But your question is referring to the "pushViewController" method, which is related to UINavigationController objects, and there is indeed a navigation controller in the background of the screenshot. You might try looking into something like this:
[currentViewController.navigationController pushViewController:vc animated:YES];

Skip UIImagePickerController Preview View?

I'm using UIImagePickerController to allow my user to select a video from the asset library.
When the UIImagePickerController is initially displayed, it shows thumbnails for the various movies that have been recorded.
Once the user selects a movie, it displays a "preview" view which allows them to playback and potentially edit the selected movie.
Is there any way to avoid displaying this view and instead return the movie that was selected on the thumbnail screen?
Here is the code I'm using:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
imagePicker.allowsEditing = NO;
[self presentModalViewController:imagePicker animated:YES];
I haven't tested this myself, though I'll be attempting this in my own application shortly. If you take a look at the UIImagePickerController showsCameraControls documentation, it alludes to the fact that if you eliminate the camera controls you can take as many photos as you want.
So theoretically if you set showsCameraControls to NO, and assign your own cameraOverlayView UIView to let the user take a photo, you can dismiss the image picker without the preview view from showing.
Perhaps that helps. You could listen with the NSNotificationCenter on #"_UIImagePickerControllerUserDidCaptureItem". If the user select the item, you could dismiss the imagePicker and do your thumbnail stuff.
I had a similar issue, to remove an overlay on the preview view and could solve it with this approach.

iPhone camera can't open from landscape application

I am creating a landscape only application using sdk 3.0 that uses mapkit. I need to use iphone camera in my application. But I am getting following warning when I try to open camera.
"Can't perform full-screen transition. The fromViewController's view must be within a view that occupies the full screen."
The view from which I am calling camera method is mapview with size of 480*320. I have written following code to call camera:
UIImagePickerController *picker = [[UIImagePickerController alloc]init];
picker.delegate = self;
picker.sourceType=UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController: picker animated:YES];
[picker release];
After that I have written the usual method :
-(void)imagePickerController : (UIImagePickerController *)picker didFinishPickingImage : (UIImage *)image editingInfo : (NSDictionary *)editingInfo
But this is never called , since camera is never opened. So my question is what am I missing here...? I am testing this app on actual iphone device , not on simulator. I have used this code in another app and it works fine. But here, it simply doesnt work! Plz help if you have any idea about this..
it sounds like the warning is telling you the problem: the parent view you're passing in to presentModalViewController needs to be a full-screen view. So instead of using "self" in this code you need to use something else, like the parent view controller.
now, you're going to have another problem, because the camera controller doesn't like landscape mode, so you may have to switch back to portrait mode before showing it....
just replace "self" with the parent ViewController which is probably declared in you appDelegate.

how can I call a screen with a button action (xcode)?

I am developing a Window Based app for iPhone. I use Interface Builder to build Interface. I want to call a new screen with a Button Action. How can I call the screen with Button action ?
By pushing the new controller onto the top of the stack of windows. For example:
EnterNameController *newEnterNameController = [[EnterNameController alloc] initWithNibName:#"EnterName" bundle:[NSBundle mainBundle]];
[[self navigationController] pushViewController:newEnterNameController animated:YES];
Apple has an extraordinary amount of sample code, and this question (as well as many others) could easily be solved by simply visiting Apple's iPhone dev site.
iPhone Dev Site
If you are using a navigation controller, push it onto the navigation controller's stack, as alamodey suggested.
If you want it to be a modal controller (that is, slide up from the bottom and cover the previous controller's view, like the Bookmarks screen in Safari), present it as a modal view controller:
[self presentModalViewController:myNewController animated:YES];
When you want to bring the old controller back, dismiss the modal view controller. From inside the modal view controller:
[self.parentViewController dismissModalViewControllerAnimated:YES];
If you don't want to do either, just remove the current controller's view from the window and add the new controller's:
UIView * containingView = self.view.superview;
[self.view removeFromSuperview];
[containingView addSubview:myNewController.view];
If you go this route, you may want to look into +[UIView beginAnimations:context:], +[UIView setAnimationTransition:onView:], and +[UIView commitAnimations] (if I recall the method names correctly--check the documentation) to animate the transition. You should almost always animate any switch between screens in iPhone OS.
(work in .m class)
#import "classtocall.h"
- (IBAction)ButtonPressed:(id)sender
{
classtocall *mvc = [[classtocall alloc]initWithNibName:#"classtocall" bundle:nil];
[self presentModalViewController:mvc animated:NO];
}
(for window based application)
define in .h class
- (IBAction)ButtonPressed:(id)sender;
where "classtocall" is the class you want to call.
you just need to download sample applications from XCode help. Try Elements and UIcatalog. There are also other - type 'pushViewController' or 'addSubview' adn 'makeKeyAndVisible' in help and download samples
nextscreenViewController *login = [[self storyboard] instantiateViewControllerWithIdentifier:#"nextscreenidentifier"];
nextscreenidentifier.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController: nextscreenidentifier animated: YES];