I have a view that contains a ECSlidingView:
Bij clicking the '+' button, you enter another view, without the ECSlidingView:
Now, I would like to return to the first view once a user clicks on the 'Voeg Toe' button in the second view. I have tried using:
FoodViewController *myController = [self.storyboard instantiateViewControllerWithIdentifier:#"Voedingsdagboek"];
[self presentViewController:myController animated:YES completion:nil];
However, now the ECSlider does not work anymore. So I cannot navigate through the rest of the application. How can I solve this?
To go back to previous view you can write popViewController in buttonTapped Method.
[self.navigationController popViewControllerAnimated:YES];
Eventually I fixed it by using:
self.slidingViewController.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"Voedingsdagboek"];
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
Related
On didSelectRowAtIndexPath I want to return to the previous viewcontroller. I'm using this code, at the moment:
[self.navigationController popViewControllerAnimated:YES];
But, I don't want to pop from navigationcontroller. Because, when the user "clicks" on back button, I want to return to this view.
So, I want to back to previous controller without popping it from navigationcontroller. It is possible?
Thanks!
Try using [self presentViewController:vc animated:YES completion:nil]; instead
It seems that you want to push the previous view controller ,you can use the UINavigtionController viewControllers attribute.
So you code may like this
[self presentViewController:[self.navigationController.viewControllers objectAtIndex:[self.navigationController.viewControllers.count-2]] animated:YES completion:nil];
im have two view controller UserListView and UserProfileView!
in UserListView view controller i'm have a button for swtich to UserProfileView and here is code.
UserListView.m - Click Action
- (IBAction)SettingClick:(id)sender
{
UserList *UserProfile = [self.storyboard instantiateViewControllerWithIdentifier:#"UserProfileView"];
[self presentViewController:UserProfile animated:YES completion:nil];
}
And code working fine, when user switch to profile (UserProfileView) have a close button back to UserListView and here is code.
UserProfileView.m - Close click action
- (IBAction)CloseClick:(id)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
UserProfile *UseList = [self.storyboard instantiateViewControllerWithIdentifier:#"UserListView"];
[self presentViewController:UseList animated:YES completion:nil];
}
in this code i will using [self dismissViewControllerAnimated:YES completion:nil]; to close UserProfileView view controller for low ram usage and it work.
But affter i close UserProfileView i want to open this view controller again and it do not work, UserProfileView not showing again??
i using xcode 5 and building an App for ios 7, please help.
Thanks for your time.
If I understand correctly, when you call SettingClick: your app is displaying a UserList. So, when you dismiss a view controller presented on top of it, you should go back to UserList without the need for presenting it again. So you can try with:
- (IBAction)CloseClick:(id)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
}
This will work unless you had originally presented UserList as well. In this case, UserList will be dismissed with the top controller. In this case, you can delay presenting a second time UserList after dismissing UserProfile, and it should work.
In the latter case, I would suggest you to use a navigation controller instead of simply presenting your controllers like you are doing. As you see, it is not really straightforward and you will get into catches of any kind. Presenting a controller works ok when you present just one controller at a time. On the other hand, if you instantiate a UINavigationController, this will handle the controllers' hierarchy for you.
use this -
- (IBAction)CloseClick:(id)sender
{
[self.navigationController popViewControllerAnimated:YES];
}
This will return to your previous view when u click that button that has been linked with this action
I'm working with SVWebViewController. When I present the view controller here
SVModalWebViewController *webViewController = [[SVModalWebViewController alloc] initWithAddress:address];
webViewController.webDelegate = self;
[self presentViewController:webViewController animated:YES completion:nil];
The view controller slides up from the bottom, as expected. However, when the view controller is dismissed, calling
[self dismissViewControllerAnimated:YES completion:nil];
The view controller simply disappears. No slide animation down. Any thoughts?
EDIT
It turns out a lot of presentation animations aren't displaying correctly in the application. Some pushes on the navigation controller aren't sliding in or sliding out (but some are). They just appear.
[self dismissViewControllerAnimated:YES completion:NULL];
This should be in SVModalWebViewController not SVWebViewController
EDIT: Instead of modally segueing to the SVWebViewController you should push:
SVWebViewController *webViewController = [[SVWebViewController alloc] initWithAddress:#"http://google.com"];
[self.navigationController pushViewController:webViewController animated:YES];
And instead of dismissing you should:
[self.navigationController popViewControllerAnimated:YES];
From SVWebViewController viewWillAppear::
SVWebViewController needs to be contained in a
UINavigationController. If you are presenting SVWebViewController
modally, use SVModalWebViewController instead.
Is your main view controller contained in a navigation controller? If not, this could possibly cause the other animation issues you're facing.
The dismissal should be from the displayed modalViewController.
It happens to me when the destination view controller loads a big picture or background
I'm developing an iPhone application with latest SDK.
I don't know how to dismiss a ViewController. I've added a back button and this is what I do:
- (IBAction)backButtonClicked:(id)sender
{
[self.navigationController dismissModalViewControllerAnimated:YES];
}
I have also tried:
[self.navigationController popViewControllerAnimated:YES];
But either works. I've added a breakpoint and it stops on it.
And I use a Modal segue to navigate to this ViewController.
How can I dismiss this View Controller programmatically?
Try [self dismissViewControllerAnimated:YES completion:nil];
- (IBAction)backButtonClicked:(id)sender
{
[self.presentingViewController dismissViewControllerAnimated:YES
completion:nil];
}
Is the VC being modally displayed an instance of your own view controller subclass, or did you wrap that inside a UINavigationController? If the former, try
[self dismissModalViewControllerAnimated:YES];
[self.presentingViewController dismiss...] will also work, but only for iOS 5+
create a custom segue,then button action choose the custom segue
http://jeffreysambells.com/2014/02/19/dismissing-a-modal-view-using-a-storyboard-segue
I have three viewController
First, Second and Third
from Second to open Third I use
Third *third = [[Third alloc]initWithNibName:#"Third" bundle:nil];
[self presentModalViewController:third animated:YES];
[third release];
Now I want return from third to first; then I set in viewDidAppear in second this code:
[self dismissModalViewControllerAnimated:NO];
but for 1 second I see Second and I don't want watch it...how can I do?
You need to dismiss third view controller first and then second Viewcontroller. Do the following code when you want to go first view controller.
-(void)goToFirstView{
UIViewController *vc = [self parentViewController];
// UIViewController *vc = [self presentingViewController]; //ios 5 or later
[self dismissModalViewControllerAnimated:NO];
[vc dismissModalViewControllerAnimated:YES];
}
How is the Third modal view being dismissed in the first place? Perhaps by the user touching a 'Done' button? If so, it is in the handler for the button that you want to dismiss both.
You can dismiss both as:
[self dismissModalViewControllerAnimated: YES];
[self.presentingViewController dismissModalViewControllerAnimated: NO];
This happens coz viewDidAppear is called everytime before the view appears so as soon as it appears you dismiss it and it disappears..
I don't think what u are trying to do can be achieved with modalViewControllers...
instead use a navigationController and keep adding your viewcontrollers onto the stack and when you want to goto the First view controller just call
[self.navigationController popToRootViewControllerAnimated:YES];
EDIT:
just thought of it this can be achieved by using delegation.. you make second the delegate of third and as soon you dismiss the thirdviecontroller send the delegate a message.In this message call [self dismissModalViewControllerAnimated:NO];..
and you are done.. (pretty easy if you know delegation.)