Add a Tab Bar Controller Programmatically to current App Flow

前端 未结 2 1477
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-31 21:17

I want to add a tab Bar Controller to my current App Flow. Currently I have a page with a button which on clicking opens a new viewcontroller with a web view where the user logs

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-31 21:41

    Set Delegate UITabBarDelegate

    here TabBar Viewcontroller image http://prntscr.com/ba5oks

    #pragma mark- Tapbar delegate
    
    - (void)deselectTabBarItem:(UITabBar*)tabBar
    {
        tabBar.selectedItem = nil;
    }
    
    - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
    {
        [self performSelector:@selector(deselectTabBarItem:) withObject:tabBar afterDelay:0.2];
    
        switch (item.tag) {
            case 0:
                //perform action
                break;
            case 1:
                //do whatever you want to do.
                break;
            case 2:
                //call method
                break;
            default:
                break;
        }
    }
    

提交回复
热议问题