0

我有一个视图控制器,它在标签栏下有一个地图视图和第二个视图。当我按下标签栏上的按钮时,如何更新第二个视图?

我试过了:

LocationNotesViewController lnvc = new LocationNotesViewController();
lnvc.View.Frame = MainPageTabBarView.Frame;
MainPageTabBarView = lnvc.View;

什么都没有发生……视图没有更新。

在此处输入图像描述

当用户点击标签栏时,我想用不同的东西更新第二个视图......

4

3 回答 3

1

If you put a UIView underlying whatever data you want displayed in it, you can use the IBAction of the tabBar to programtically cahnge out the contents of the UIView.

Or you could have the IBActions of the tabbar create new UIViews on the fly, containing whatever you want inside.

Code to do this would be like explained here: http://www.programmerscountry.com/creating-uiviewcontrols-programatically/.

Not exactly the same, but you will understand how it works from that answer.

于 2013-07-19T19:28:28.000 回答
0

我认为这是一种解决方法 - 但我能够通过以下方式实现:

LocationNotesViewController lnvc = new LocationNotesViewController();
lnvc.View.Frame = new RectangleF(MainPageTabBarView.Frame.X, MainPageTabBarView.Frame.Y -    MainPageTabBarView.Frame.Y, MainPageTabBarView.Frame.Width, MainPageTabBarView.Frame.Height);
MainPageTabBarView.AddSubview(lnvc.View);
于 2013-07-19T19:50:06.463 回答
0

要切换 UIViewControllers,请使用以下代码:

UIViewController *viewController = 
                 [self.storyboard instantiateViewControllerWithIdentifier:@"4"];
                 [self presentViewController:a animated:YES completion:nil];
于 2013-07-19T18:31:44.520 回答