gpt4 book ai didi

iphone - 添加 TabBar 元素

转载 作者:行者123 更新时间:2023-11-29 11:15:14 24 4
gpt4 key购买 nike

我正在做一个项目,其中第一个 View 不应该包含任何标签栏,当按下 View 时,它应该作为翻页移动。然后从下一页开始,应该显示标签栏项目。如果我是正确的,我认为 tabbarcontroller 不会帮助我实现上述目标。所以我添加了一个标签栏元素。但是如何将按钮操作赋予标签栏元素中的标签栏项目,以便在按下标签栏按钮时将每个 View 加载为标签栏 Controller 的 View 。任何帮助表示赞赏。谢谢

最佳答案

为了翻转 View ,实现这个..

[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:0.80];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:self.navigationController.view cache:NO];
[self.navigationController pushViewController:self.detailviewcontyrollerObj animated:YES];
[UIView commitAnimations];

你想要第二个 View 的标签栏,所以在第一个 View 中点击一个按钮(或其他任何东西),编写从应用程序委托(delegate)调用函数的代码..

-(IBAction)clickme
{
AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication]delegate];
[app SwitchToTabbarController];
}

现在,在 app delegate 中,声明名为 SwitchToTabbarController 的方法,在其中实现 this..

 _tabBarController = [[UITabBarController alloc] init];
FirstViewController *view1 = [[FirstViewController alloc] init];
SecondViewController *view2 = [[SecondViewController alloc]init];

UINavigationController *tbl1=[[[UINavigationController alloc] initWithRootViewController:view1] autorelease];
tbl1.navigationBar.barStyle = UIBarStyleBlackOpaque;

tbl1.navigationBarHidden=NO;

UINavigationController *tbl2=[[[UINavigationController alloc] initWithRootViewController:view2] autorelease];
tbl2.navigationBar.barStyle = UIBarStyleBlackOpaque;

tbl2.navigationBarHidden=NO;
_tabBarController.viewControllers = [NSArray arrayWithObjects:tbl1,tbl2,nil];

[_window addSubview:_tabBarController.view];
self.window.rootViewController = self.tabBarController;
[_window makeKeyAndVisible];

整体实现会很有帮助,我认为这就是您想要的......:)

关于iphone - 添加 TabBar 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9747016/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com