0

所以,目前,我正试图将相同的传递UINavigationBar给多个UIViewControllers。

例如,假设我有 aUINavigationController的视图是 aUIViewControllerUIView。在 custom中UIViewControllerUIView我修改了 UINavigationBar 的内容titleview

UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(self.navigationController.navigationBar.frame.origin.x + 50, self.navigationController.navigationBar.frame.origin.y, self.navigationController.navigationBar.frame.size.width - 100, 44)];
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
button1.frame = CGRectMake(35, titleView.frame.origin.y + 2, 40, 40);
[button1 setImage:[UIImage imageNamed:@"FacebookFriendRequestIcon.png"] forState:UIControlStateNormal];
[button1 addTarget:self action:@selector(FriendRequestsPopover:) forControlEvents:UIControlEventTouchUpInside];
[titleView addSubview:button1];
UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
button2.frame = CGRectMake(80, titleView.frame.origin.y + 2, 40, 40);
[button2 setImage:[UIImage imageNamed:@"FacebookMessagesIcon.png"] forState:UIControlStateNormal];
[button2 addTarget:self action:@selector(MessagesPopover:) forControlEvents:UIControlEventTouchUpInside];
[titleView addSubview:button2];
UIButton *button3 = [UIButton buttonWithType:UIButtonTypeCustom];
button3.frame = CGRectMake(125, titleView.frame.origin.y + 2, 40, 40);
[button3 setImage:[UIImage imageNamed:@"FacebookNotificationsIcon.png"] forState:UIControlStateNormal];
[button3 addTarget:self action:@selector(NotificationsPopover:) forControlEvents:UIControlEventTouchUpInside];
[titleView addSubview:button3];

self.navigationItem.titleView = titleView;

当用户按下 UIViewcontroller 中的按钮(不指导航栏的项目)时,用户会被推送到另一个UIViewController

GeneralInfoViewController *generalInformationController = [[GeneralInfoViewController alloc] init];
[self.navigationController pushViewController:generalInformationController animated:YES];

UIViewController1(UINavigationController) pushes to UIViewController2(UINavigationController)

因此,generalInformationController被子类化为UIViewController。现在,当推送发生时,我希望发生动画,但仅限于UIView' 而不是 NavigationBar。

一个示例应用程序就像 Facebook,导航栏的中间按钮(消息、好友请求和通知)总是可见的,并且当视图控制器被压入堆栈时永远不会动画消失。

有人对如何做到这一点有任何想法吗?我想理论上的答案会很好,但编码示例会更好:)

4

2 回答 2

0

一个示例应用程序就像 Facebook,导航栏的中间按钮(消息、好友请求和通知)总是可见的,并且当视图控制器被压入堆栈时永远不会动画消失。

这可能是 Facebook 应用程序不使用导航控制器的线索。我不知道它是否这样做,但编写自己的容器视图控制器可能比尝试强制 UINavigationController 以不符合设计的方式运行更容易。

于 2013-08-18T07:20:22.503 回答
0

如果您使用导航控制器进行推送和弹出,您不能让您的导航栏停留在他的位置;但是你可以试试:

newView.bounds = mainView.bounds; //newView can be nextViewController.view
newView.biunds.size.height=newView.biunds.size.height-self.navBar.bounds.size.height; //devide navBar height
newView.frame = CGRectMake(newView.frame.origin.x + 784, newView.frame.origin.y, newView.frame.size.width, newView.frame.size.height);
[mainView addSubview:newView];

/* Begin transition */
[UIView beginAnimations:@"Slide Left" context:oldView];
[UIView setAnimationDelegate:self];
[UIView setAnimationDelay:0.0f];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationDidStopSelector:@selector(slideInCompleted:finished:context:)];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
newView.frame = CGRectMake(0,0, newView.frame.size.width, newView.frame.size.height);
oldView.frame = CGRectMake(oldView.frame.origin.x - 784, oldView.frame.origin.y, oldView.frame.size.width, oldView.frame.size.height);
[UIView commitAnimations];

发表评论,为您的结果。

于 2013-08-18T07:24:10.923 回答