I have a viewcontroller, and I would like to display a modal view controller with :
presentModalViewController when a user finished picking an image.
The modal view controller is working fine when I call it from a button in my main view.
But when I call it from didfinishpickingimage callback nothing happens.
Thanks.
Try
[picker dismissModalViewControllerAnimated:NO];
before
[self presentModalViewController:MY_VIEW_CONTROLLER animated:YES];
Note the animated variable
I had a similar issue. I decided to push the view controller I wanted to display after selecting an image onto my navigation controller instead of trying to present a modal view controller. It has the same effect as presenting a modal.
So I just did:
[self.navigationController pushViewController:MY_VIEW_CONTROLLER animated:YES];
Related
I wan't to flip from one view controller to another for that i used following coding on button click
-(void)ClicOnLogout {
LogOutViewController *logOut=[[LogOutViewController alloc]initwithnName:str];
logOut.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:logOut animated:YES];
}
but when i m in logout view controller there is one button but it won't work so can any one give me the proper solution for it.
Thanx...
You should read that Apple documentation article on Modal View Controllers which explains everything you are asking there. Basically what you need to do on your logout view is to call :
[self dismissModalViewControllerAnimated:YES];
By calling this, the back (left-to-right) flip animation will be done automatically :
UIModalTransitionStyleFlipHorizontal
When the view controller is presented, the current view initiates a horizontal 3D flip from right-to-left, resulting in the revealing of the new view as if it were on the back of the previous view. On dismissal, the flip occurs from left-to-right, returning to the original view.
You can call the popViewControllerAnimated method:
[self.navigationController popViewControllerAnimated:YES];
or you can assign it to push it onto the navigation controllers stack:
[self.navigationController pushViewController: viewController animated:YES];
I'm trying to build an app that features a button on the first view, when you tap the button it presents the UIImagePickerController modal view. What I would ideally like is once you have taken you photo, when the modal view is dismissed, the original view which presented the image picker changes.
For example, the process would be VIEW 1 -- (tap button) --> MODAL IMAGE PICKER -- (close modal view) --> VIEW 2.
So far I've got the app loading the UIImagePickerController and once you are complete, within the didFinishPickingMediaWithInfo delegate method, it sets a BOOL value to YES and then within the ViewDidAppear of my original view (VIEW 1) it then presents a new modal with the next view.
The problem with this is that there is a delay between the closing the modal view and the next view (VIEW 2) appearing.
Does anyone know if the above is possible? If not, I might have to resort to displaying a spinner and saying "Processing image" between the image picker closing and the second view appearing.
You can use a navigation controller to solve this problem.
Create a navigation controller and push your first controller into it. Later from your first controller, present the picker modally. Pretty much the same until now except that we have added a navigation controller. This is what I did to get your desired result.
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NewController *controller = [[NewController alloc] initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:controller animated:YES];
[self dismissModalViewControllerAnimated:YES];
[controller release];
}
Hope this helps.
I am using a split view controller in an iPad app I am trying to make.
Right now, I have a view being displayed in a modal view controller using:
[self presentModalViewController:viewController animated:YES];
and that works fine, but when the user presses a button, I want the root view controller to push to another view. I am using:
RootViewController *rvc = [[RootViewController alloc] initWithNibName:#"RootViewController" bundle:nil];
[rcv pushViewController:rvc animated:YES];
but that is not working. What should I do?
--EDIT
Now, I am using
PhotosViewController *pv = [[PhotosViewController alloc] initWithNibName:#"PhotosViewController" bundle:nil];
[self.parentViewController.navigationController pushViewController:pv animated:YES];
NSLog(#"Navigation Controller: %#", self.parentViewController.naviagtionController);
When I do the NSLog call, it returns nil. Why is that?
Once again, I am using a split view controller and am trying to push the RootViewController to a new view.
Thanks
Your code isn't working because you're created a RootViewController instance and then trying to push it onto itself. What you should be doing is pushing the new view controller onto the parent view controller's navigation controller:
[self.parentViewController.navigationController pushViewController:newViewController animated:YES];
I know this is an old question but I believe the proper way "now" to push a viewController onto the main navigation stack from a modal viewController is to create a "didTapShowBlahViewController" delegate on the modal (this is assuming you want the user to be finished with the existing modal view and then push a new view onto the stack). Once you have that delegate, you simply have the view that initially invoked the modal to perform dismissing the modal and pushing the next view controller when the delegate is triggered.
- (void)didTapShowBlahViewController{
[self dismissViewControllerAnimated:YES completion: nil];
[self performSegueWithIdentifier:#"segueToBlahViewController" sender:self];
}
This is based on Apple's View Controller Programming Guide that specifies passing data to child view controllers and using delegates to pass data back to parents.
FYI: This way also ensures that the "back" button will not go back to the modal but instead to the view that invoked the modal, which is how modals are typically used.
When I click the table row, go back to previous view without clicking back button.
I try
[self.navigationController dismissModalViewControllerAnimated:YES];
it's not working. How to dismiss pushViewController ?
dismissModalViewControllerAnimated is used to dismiss a Modal View Controller. These are the view controllers that slide up from the bottom of the screen. An example would be when you tap the button to compose a new email in the Mail app.
If you want the navigation controller to pop back to the previous view controller try using
[self.navigationController popViewControllerAnimated:YES];
Here's a link to the documentation for UINavigationController
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UINavigationController_Class/
[self.navigationController popViewController:YES]
With that line you are dismissing a modal view. That is not the same thing as popping controllers from the navigation controller stack.
You should instead do this:
[self.navigationController popViewControllerAnimated:YES];
This will pop the top controller.
Here is a link to the documentation.
I have image picker which collects data for another view controller (TTMessageController from three20) and I want this message composer to appear behind image picker, so when image piker slides out there will be already appeared message controller with pre-filled data.
Code like this
[self.navigationController presentModalViewController:composeController animated:NO];
[picker dismissModalViewControllerAnimated:YES];
and vice-versa wont work at all. What to do? How to present composeController behind already presented picker controller?
Thanks in advance.
Actually removing animation from both viewController help.
[picker dismissModalViewControllerAnimated:NO];
[self presentModalViewController:composeNavController animated:NO]; // If YES it crashes
But it's not to iPhone-ish if get what I mean, even fade throw black or just some visual effect will make it look much, much nicer. Technically tho, it works.
Edit:
Ok I think the problem here is the modal bit, as the iPhone really appears to not like you having 2 views set to modal, or even animating from one modal view to another.
Do they definitely have to be modal? How about adding them to the normal navigation stack?
You could add the message view to the stack first (non-animated) so that it's there when you pop back one.
Try this:
The order in which you add views to the stack affects the order that they will display in when you dismiss them.
This part adds the composeController to the stack and then animates the picker going on top. Use this code to display the picker controller (ie instead of modal dialog):
[self.navigationController pushViewController:composeController animated:NO];
[self.navigationController pushViewController:picker animated:YES];
Then, when you are done with the picker, you can "pop" the view back to the message composer:
[self.navigationController popViewControllerAnimated:YES];
You should now have no references to any modal dialogs remaining in your code. I believe this should work much better than modal, which really is for displaying one view above every other one, not for switching from view to view.
Hope that helps!
Instead of trying to present another viewController behind the picker, you could dismiss the image picker modal view controller, push the Message controller (both with animated:NO), and then use a CATransition to perform your own Cocoa-like animation of the image picker animating off screen.
You need to split these animations up so they don't execute in the same runloop. I've run into a situation where the OS does not like dismissing and presenting modal views back to back.
Try this:
- (void)myCallbackMethod{
[picker dismissModalViewControllerAnimated:YES];
[self performSelector:#selector(presentMessage) withObject:nil afterDelay:0.25];
}
- (void)presentMessage{
[self.navigationController presentModalViewController:composeController animated:YES];
}