我怎样才能推动从目标C视图点击按钮后,标签栏控制器? [英] How can I push tab bar controller after click a button from a view in objective c?

查看:120
本文介绍了我怎样才能推动从目标C视图点击按钮后,标签栏控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个观点的一个按钮,我想添加标签栏控制器点击按钮后。我怎样才能做到这一点?

I have a button in a view, I want to add tab bar controller after click the button. How can I do this?

推荐答案

首先,我不认为推作为一个子视图标签栏是一个很好的主意。

first of all, i don't think pushing a tab bar as a subview as a good idea

但如果你仍然想这样做,有很多的方法来解决。

but if you still want to do this, there's a lot of way to work around

其中之一是通过使用modalview

one of them is by using modalview

首先,你必须让你的按钮后,添加此code

first you have to add this code after you make the button

[button addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];

它附加一个事件监听器按钮,您可以

it attach an event listener to the button you have

接下来,使事件函数做标签栏推

next, you make the event function to do the tab bar pushing

-(void)buttonTapped: (UIButton *)sender
{
        YourTabBarClass *myTabBar = [[YourTabBarClass alloc]initWithNibName:nil bundle:nil];
        myTabBar.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

        [self presentModalViewController:myTabBar animated:YES];
}

和不要忘记导入tabbarcontroller类的头文件在您的m

and dont forget to import the tabbarcontroller class header file in your .m

#import "YourTabBarClass.h"

希望这有助于;)

hope this help ;)

编辑:如果你需要去从标签栏视图到previous菜单回来,你可以添加一个按钮,给它一个事件侦听器,并且把这种code里面的函数

edit : if you need to go back from the tab bar view into the previous menu, you can add a button, give it an event listener, and put this code inside the function

[self resignFirstResponder];
    [self dismissModalViewControllerAnimated:YES];

这篇关于我怎样才能推动从目标C视图点击按钮后,标签栏控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆