开发者

uiview in navigation

I am working with a navigation application. I have a hom开发者_如何学PythoneViewController 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜