I am working with a navigation application. I have a homeViewController with two views(accept, service). When I click on a button in serviceView it should go to acceptView. I should have back button in navigation bar which takes me be back to serviceView from acceptView. When I am trying to use [self navigationController pushViewController, it only accepts viewcontroller but not view. Can any one please tell the alternative. Please help me.
Thanks in advance
You should have a different viewController
for each view if you wish to use a navigationController
properly.
Set up AcceptViewController
and ServiceViewController
separately. Then, from the AcceptViewController
, you can create a ServiceViewController
and push it onto the stack as follows:
-(void)showServiceView {
ServiceViewController *serviceViewController = [[ServiceViewController alloc] init];
[self.navigationController pushViewController:serviceViewController];
[serviceViewController release];
}
Assuming you've references to both acceptView
and serviceView
, you can just make this work by removing one as the subview and adding the other one as the subview of homeViewController
's view
. Something like,
[serviceView removeFromSuperview];
[self.view addSubview:acceptView];
for moving to acceptView
. Switch them if you want to come back. However this mechanism will be abrupt. Use UIView
's transitionFromView:toView:duration:options:completion:
method to animate the transition. Something like,
[UIView transitionFromView:serviceView
toView:acceptView
duration:0.5f
options:UIViewAnimationOptionTransitionFlipFromLeft| UIViewAnimationOptionCurveEaseInOut
completion:NULL];
This will remove serviceView
and add acceptView
as the subview along with a transition to go by.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.