gpt4 book ai didi

iphone - 在 UITabbar 中使用默认图标

转载 作者:行者123 更新时间:2023-12-03 19:06:23 26 4
gpt4 key购买 nike

我在我的应用程序中使用选项卡栏控件,并希望在我的选项卡之一中使用默认搜索图标。我正在以编程方式制作选项卡栏,但我无法找到可以指定我在苹果文档中找到的 UITabBarSystemItemSearch 项目的属性。以下是我的标签栏代码

CouponsViewController *coupons = [[CouponsViewController alloc] init];
UINavigationController *couponsNavigationController = [[UINavigationController alloc] initWithRootViewController:coupons];
couponsNavigationController.tabBarItem.title = @"Coupons";
couponsNavigationController.navigationBar.tintColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.1];
[coupons release];

SettingsViewController *settings = [[SettingsViewController alloc] init];
UINavigationController *settingsNavigationController = [[UINavigationController alloc] initWithRootViewController:settings];
settingsNavigationController.tabBarItem.title = @"Settings";
settingsNavigationController.navigationBar.tintColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.1];
[settings release];

ProfileViewController *profile = [[ProfileViewController alloc] init];
UINavigationController *profileNavigationController = [[UINavigationController alloc] initWithRootViewController:profile];
profileNavigationController.tabBarItem.title = @"Profile";
profileNavigationController.tabBarItem.image = [UIImage imageNamed:@"profileImg.png"];
profileNavigationController.navigationBar.tintColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.1];
[profile release];

[tabBarController setViewControllers:[NSArray arrayWithObjects:loyaltyNavigationController,searchNavigationController,couponsNavigationController,settingsNavigationController,profileNavigationController,nil] animated:NO];
tabBarController.delegate=self;
tabBarController.selectedIndex=0;

[window addSubview:tabBarController.view];

最佳答案

在您要放入选项卡栏中的 UIViewController 子类中执行此代码。这最好在 View Controller 的初始化方法中完成:

- (id) init
{
self.title = @"search";
self.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemSearch
tag:0];

return self;
}

关于iphone - 在 UITabbar 中使用默认图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2627579/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com