0

我正在尝试从一个 Tabbar 索引移动到另一个 Tabbar 索引,但它无法工作。实际上,当应用程序加载显示标签栏 1 时,默认情况下我有三个标签栏索引。

在 0 标签索引处,我有我的帐户页面,当有人按 Tabbar 0 时,我不想直接访问我的帐户标签栏(无需登录),然后登录页面在用户成功登录时在登录页面打开,然后我使用以下方法显示第一个标签栏。

// define the target method
-(void) targetMethod:(NSTimer *) theTimer
{
    sessId = wsobject.sessId;
    singletonOjb = [SingletonClass sharedManager];
    singletonOjb.sessId = sessId;
    singletonOjb.Username = wsobject.getname;

    if (sessId != NULL)
    {
        singletonOjb.password = password.text;
        userName.text = @"";
        password.text = @"";
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        [self storeFavObj];
        [self dismissViewControllerAnimated:YES completion:nil];
        self.tabBarController.selectedIndex = 0;
    }
    else
    {
        //userName.text = @"";
        password.text = @"";
        [MBProgressHUD hideHUDForView:self.view animated:YES];
    }
}
4

2 回答 2

2

如果您的意思是在标签栏中选择不同的标签栏项目,这就足够了。

[tabBar setSelectedIndex:0];
于 2013-05-17T09:54:28.657 回答
0
self.tabBarController.selectedIndex = 1;

而不是 1 使用您需要放置的索引

于 2013-05-17T10:24:24.067 回答