如何从 UITabBar
中删除 UITabBarItem
?
我还没有尝试过任何东西,因为我没有从 Google 搜索或 UITabBar
、UITabBarController
或 UITabBarItem
的文档中找到任何内容>.
提前致谢! :)
最佳答案
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/