I have a switched the cameracontrolls off, i mean
pickerCam.showsCameraControls=NO;
and i have custom capture button which does the capture functionality,
[pickerCam takePicture];
on click of this button the delegate will be called,
- (void)imagePickerController:(UIImagePickerController *)pi didFinishPickingMediaWithInfo:(NSDictionary *)info
Instead i need to implement custom 'Use' and 'Retake' option , how do i do that.
Thanks in advance
In imagePickerController:didFinishPickingMediaWithInfo: Method save the image captured in a global varialbe
Add a view to overlay having Use and Retake Button,
In the Use target dismiss the picker.
In retake target remove the view having Use and Retake buttons.
Related
I have a class which has UIImagePickerController and extends UIViewController. But viewWillAppear/viewDidAppear are not being called for this class. Why so?
I want viewWillAppear to be there so that when I come back to this view, I can make some change.
By coming back you mean coming back from UIImagePickerController after selecting image/media?
If you want to display the image/media you selected from UIImagePickerController in your view,
you can make changes in the UIImagePickercontroller delegate method :
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
which gets called as soon as you select any image or media from imagePicker. You just need to set the delegate of imagePicker to the the class in which you want to display the images.
I know this is a hot question for iPhone programming but I can't find a good answer yet.
I've an UITabBarController based application with the middle tabBarItem overlayed by a custom button. This custom button is used for posting a new item. Like this (I take Instagram, for example).
Of course this button must be accessible in the whole application.
When you click on this button you'll can see an UIImagePickerController for choosing an image from your library or from the camera.
The problem is how to display another UIViewController after you've chosen the image.
The first method is set a boolean variable from the UIImagePickerController delegate method and override the viewDidAppear method of all view controllers for checking the boolean var and if it's TRUE, call [self.tabBarController presentModalViewController:MyController animated:YES]. But I think this one is pretty ugly.
Have you others (elegant) method?
Create a new UIImagePickerControllerDelegate object, trap user actions, and either present a modal view controller or send a message to a view controller to handle it.
Let's say ViewController A is the class where you click on the camera button starting UIImagePickerController. ViewController Ashould be the delegate of UIImagePickerController.
Then, in ViewController A class, we define the function which is called when you click on the button Use.
// This function is invoked when you click the button USE
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Go back to the view A
[self dismissModalViewControllerAnimated:NO];
// Get Image
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
// Go to view B
[self.navigationController pushViewController:showMapViewController animated:NO];
I want Button action done automatically when a view load. Is it possible?
The other answers are correct in that setting the action that your button is tied to, then in your viewDidLoad:, call that function will work. I will just chime in with another method for others info.
You can send it a control event telling it that the button should act as if it has been pressed:
[button sendActionsForControlEvents:UIControlEventTouchUpInside];
This is useful when you do not have an outlet to the button. For instance, I created an app where the user can press on a web view and launch a youtube video. It was also required that if the user presses a "video" button, then the same youtube video would launch. Basically, I had to fire a press event on the web view. So i searched through its views and found the button, from there I called the above line, and the webview pushes a video view controller for the youtube video.
Certainly Yes. Call your method as
assuming your method declaration as
-(IBAction)yourButtonTapEvent:(id)sender;
[self yourButtonTapEvent:nil];
Yes, in your viewDidAppear method, just call the action you are providing for that specific button.
- (void)viewDidAppear:(BOOL)animated
{
[self yourButtonAction:nil];
[super viewDidAppear:animated];
}
I'm working with tabBarBased application.At the time of clicking the one of the tabBarButton it opens the photo album .In photo album there is a cancel button on top(navBar) right??Here i want to perform action event for cancel button click...while click on the cancel button i want to go to the another tabBar view...
Please help me out to do this...
Thank You in advance for your consideration and effort...
Regards,
Renuga
Here's the class definition for UIImagePickerControllerDelegate:
#protocol UIImagePickerControllerDelegate<NSObject>
#optional
// The picker does not dismiss itself; the client dismisses it in these callbacks.
// The delegate will receive one or the other, but not both, depending whether the user
// confirms or cancels.
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA,__MAC_NA,__IPHONE_2_0,__IPHONE_3_0);
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info;
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker;
#end
I think one of the methods mentioned above is what you need:
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker;
set the selectedViewController property of UITabBarController to the view controller you want to switch to. Assigning a new view controller to this property changes the currently displayed view and also selects the appropriate tab in the tab bar.
I have a UIImagePickerController subclass, and I would like to detect when the user presses the "retake" button.
Is that possible... what delegate method gets called? I looked at the docs but I can't find anything: http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIImagePickerControllerDelegate_Protocol/UIImagePickerControllerDelegate/UIImagePickerControllerDelegate.html
EDIT: I am accepting the answer, though this requires you build to OS 3.1
You could remove the default controls with:
picker.showsCameraControls = NO;
and implement a cameraOverlayView with your own retake button, that calls the takePicture function on the UIImagePickerController again.