OGeek|极客世界-中国程序员成长平台

标题: ios - xcode标签栏 Controller 用代码更改所选项目 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 12:17
标题: ios - xcode标签栏 Controller 用代码更改所选项目

首先,我使用的是 Xcode 6 和 Objective-c。我想用按钮或用代码自动更改标签栏屏幕我该怎么做。另一个问题可能是我做这个不同的 View 而不是标签栏 Controller 的项目。

- (IBAction)backButtonid)sender
{
    ProfileSide *vc = (ProfileSide *)[[self.tabBarController viewControllers]objectAtIndex:1];
    [vc.view setNeedsDisplay];
    [self.tabBarController setSelectedViewController:vc];
}

我尝试了此代码部分但无法正常工作。 ProfileSide 类第 3 项标签栏 Controller 的名称。

ProfileSide *vc1 = [self.storyboard instantiateViewControllerWithIdentifier"meScreen"];
[self presentViewController:vc1 animated:YES completion:nil];

也有这个代码部分,但是当我使用这个标签栏时会消失。



Best Answer-推荐答案


[self.tabBarController setSelectedIndex:yourIndex];

关于ios - xcode标签栏 Controller 用代码更改所选项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26588767/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4