IOS tabbar的跳转

第一种方案:

    AppDelegate * appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;

    UIViewController * controller = appDelegate.window.rootViewController;

    UITabBarController * tabBarController = (UITabBarController *)controller;

    [tabBarController setSelectedIndex:3];

    //假如要跳转到第四个tabBar那里,因为tabBar默认索引是从0开始的

    [self.navigationController popToRootViewControllerAnimated:YES];


第二种方案:

    self.navigationController.tabBarController.selectedIndex = 3;

第三种方案:

self.tabBarController.selectedIndex = 3;

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • //设置尺寸为屏幕尺寸的时候self.window = [[UIWindow alloc] initWithFra...
    LuckTime阅读 833评论 0 0
  • 前言 最近忙完项目比较闲,想写一篇博客来分享一些自学iOS的心得体会,希望对迷茫的你有所帮助。博主非科班出身,一些...
    GitHubPorter阅读 1,452评论 9 5
  • 前言的前言 唐巧前辈在微信公众号「iOSDevTips」以及其博客上推送了我的文章后,我的 Github 各项指标...
    VincentHK阅读 5,418评论 3 44
  • 接《iOS知识点大总结一》 三十四、主线程操作UI(对UI进行更新只能在主线程进行) 解释:所谓的在主线程更新UI...
    RunningMan_Fly阅读 1,460评论 0 0
  • UIView是iOS开发中所有视图的基类, 表示屏幕上的一块矩形区域, 同时可以处理该区域的绘制和触摸事件. UI...
    icetime17阅读 2,256评论 1 4