iphone - 删除 UITabBarItem

标签 iphone uitabbar uitabbaritem iphone-sdk-4.1

如何从 UITabBar 中删除 UITabBarItem

我还没有尝试过任何东西,因为我没有从 Google 搜索或 UITabBarUITabBarControllerUITabBarItem 的文档中找到任何内容>.

提前致谢! :)

最佳答案

UITabBar有一个 NSArray元素的集合。由于 items 属性是 NSArray 而不是 NSMutableArray ,您必须从现有的没有要删除的对象的 NSArray 构造一个新的 NSArray,然后将 items 属性设置为新数组。

/* suppose we have a UITabBar *myBar, and an int index idx */
NSMutableArray *modifyMe = [[myBar items] mutableCopy];
[modifyMe removeObjectAtIndex:idx];
NSArray *newItems = [[NSArray alloc] initWithArray:modifyMe];
[myBar setItems:newItems animated:true];

关于iphone - 删除 UITabBarItem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4037160/

相关文章:

ios - 设置 UITabBarItem 角标(Badge)

ios - ios13-unSelectedItem的UITabBar tintColor不起作用

swift - 在 Swift 中删除/隐藏 UITabBarItem

iphone - 是否可以更改 UITabBarItem 角标(Badge)颜色

ios - UITabBarItem 图像为蓝色且未更改

iphone - 隐藏来自 fiddler 的 iOS HTTPS 调用

iphone - 苹果应用商店的更新审核流程是否比新应用更快?

objective-c - 将声音与NStimer iPhone SDK同步?

ios - 如何减少 UITabBarItem 图像和文本之间的垂直填充?

iphone - 在Objective-C中替换字符串中的多个字符?