自定义 UItabBar 项目顺序

发布于 2024-10-08 19:06:45 字数 93 浏览 6 评论 0原文

我想更改 UITabBar 项目的顺序。
然后当我再次登录时,顺序应该保持不变。

如何做到这一点?有人可以帮助我吗?我浪费了一整天的时间来实现这个。

I want to change the order of UITabBar items.
Then when I log in again, the order should be maintained.

How this can be done? Can anybody help me? I've wasted a whole day to implement this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彩虹直至黑白 2024-10-15 19:06:45

如果您愿意以编程方式执行此操作,那么它应该相当简单:
保留每个视图的索引,然后以相同的顺序将每个视图添加到数组中进行加载:

  //construct your view controllers somehow and add them to an array in the order you want them to be:
    [myArr addObject:viewCon1];
    [myArr addObject:viewCon3];
    [myArr addObject:viewCon2];

使用数组构建标签栏

_tabControl = [[UITabBarController alloc] init];
[_tabControl setViewControllers:myArr  animated:YES]; 

if you are willing to do it programmatically it should be fairly simple:
Persist the index of each view and then add each view to an array in the same order doing load:

  //construct your view controllers somehow and add them to an array in the order you want them to be:
    [myArr addObject:viewCon1];
    [myArr addObject:viewCon3];
    [myArr addObject:viewCon2];

construct your tabbar using your array

_tabControl = [[UITabBarController alloc] init];
[_tabControl setViewControllers:myArr  animated:YES]; 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文