我有一个使用各种视图控制器作为选项卡的应用程序.当应用关闭时,我正在保存自定义标签顺序.我正在尝试为各种视图控制器找到通用标识符,而无需向每个控制器添加属性(我的备份计划).
我认为,类似于UILabels,可能视图控制器会支持标记或类似的东西?我在查找文档时遇到问题,那么有没有办法在我的UITabBarController中标记或以其他方式唯一标识每个视图控制器?
我有一个应用程序,它使用一个标签栏控制器和一个导航控制器.但是对于某些页面,我想隐藏两个栏(标签和导航)之后,那些将再次可见...我能够隐藏导航栏并且还完成了制作.它出现在一些页面之后.我可以隐藏标签栏 - (BOOL)hidesBottomBarWhenPushed {return TRUE; }
但问题是如何在某些页面后再次显示它?
热到自定义导航栏出现在UITabBarController的"更多"选项卡上,以2 px线(不同颜色)作为底部边框?
我创建了UINavigationBar的子类,它覆盖了drawrect:方法并绘制了该行,并且适用于前四个选项卡,除了更多导航控制器下的选项卡.
有帮助吗?

我需要将图像添加到tabbarcontroller.我将navigationcontroller作为tabbarcontroller中的tabbar项包含在内.那么如何将图像添加到tabbarcontroller.
tabBarController = [[UITabBarController alloc] init];
tabBarController.moreNavigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
tabBarController.moreNavigationController.topViewController.view.backgroundColor=[UIColor clearColor];
tabBarController.delegate=self;
Dashboard_iPhone *dash = [[Dashboard_iPhone alloc] init];
UINavigationController *tabItem0 = [[[UINavigationController alloc] initWithRootViewController:dash] autorelease];
tabItem0.view.backgroundColor=[UIColor clearColor];
TrackProgram_iPhone *rep = [[TrackProgram_iPhone alloc] init];
UINavigationController *tabItem1 = [[[UINavigationController alloc] initWithRootViewController:rep] autorelease];
tabBarController.tabBarItem.title=@"TrackProgram";
tabItem1.view.backgroundColor=[UIColor clearColor];
TrackClinic_iPhone *loc = [[TrackClinic_iPhone alloc] init];
UINavigationController *tabItem2 = [[[UINavigationController alloc] initWithRootViewController:loc] autorelease];
tabBarController.tabBarItem.title=@"TrackClinic ";
tabItem2.view.backgroundColor=[UIColor clearColor];
tabBarController.viewControllers=[NSArray arrayWithObjects:tabItem0,tabItem1,tabItem2,nil];
[self.view insertSubview:tabBarController.view belowSubview:dash.view ];
[self presentModalViewController:tabBarController animated:NO];
Run Code Online (Sandbox Code Playgroud)
请帮我添加图像到tabbarcontroller.
我添加了代码来制作带有导航功能的tabbar应用程序.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
ChatVC *objChatVC = [[ChatVC alloc]init];
UpdateMeContactVC *objUpdateMeContact = [[UpdateMeContactVC alloc]init];
cardsVC *objCardsVC = [[cardsVC alloc]init];
settingVC *objSettingVC = [[settingVC alloc]init];
NotificationVC *objNotificationVC = [[NotificationVC alloc]init];
self.objNavConChat = [[UINavigationController alloc]initWithRootViewController:objChatVC];
self.objNavConContact = [[UINavigationController alloc]initWithRootViewController:objUpdateMeContact];
self.objNavConCards = [[UINavigationController alloc]initWithRootViewController:objCardsVC];
self.objNavConNotification = [[UINavigationController alloc]initWithRootViewController:objNotificationVC];
self.objNavConSetting = [[UINavigationController alloc]initWithRootViewController:objSettingVC];
self.objTabBarController = [[UITabBarController alloc]init];
self.objNavConChat.title = @"Chat";
self.objNavConContact.title = @"Contacts";
self.objNavConCards.title = @"Cards";
self.objNavConNotification.title = @"Notification";
self.objNavConSetting.title …Run Code Online (Sandbox Code Playgroud) 出于这个问题的目的,我展示了我的视图层次结构的精简版本。我的应用程序包含一个UITabBarController作为基础。每个选项卡最顶部的视图控制器是一个导航控制器,并且每个视图控制器都嵌入了视图控制器。
让我们拿第一个标签。
UITabBarController -> UINavigationController -> UITableViewController -> UIViewController
假设UITableViewController实例是某种列表,而UIViewController是详细视图。当用户点击列表中的项目时,它会将您带到详细信息视图。当发生这种情况时,我已将UIViewController'shidesBottomBarWhenPushed属性设置为,true以便当用户处于详细视图时底部的标签栏将隐藏。
我的应用程序接收推送通知。当点击它们时,它应该直接打开到详细视图。我可以让它在那里导航。但问题是底部的标签栏仍然可见!
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
window = UIWindow(frame: UIScreen.main.bounds)
let tabBarController = storyboard.instantiateViewController(withIdentifier: "TabBarController") as! TabBarController
if openingFromPush {
let firstNavigationController = storyboard.instantiateViewController(withIdentifier: "FirstNavigationController") as! UINavigationController
let tableViewController = storyboard.instantiateViewController(withIdentifier: "TableViewController") as! TableViewController
let viewController = storyboard.instantiateViewController(withIdentifier: "ViewController") as! ViewController
viewController.hidesBottomBarWhenPushed = true
firstNavigationController.viewControllers …Run Code Online (Sandbox Code Playgroud) uitabbarcontroller uiviewcontroller uinavigationcontroller ios swift
我有一个包含五个项目的标签栏,我试图添加一个功能,当用户再次点击标签栏项目时滚动到顶部。添加UITabBarControllerDelegate到我想触发事件的视图中,并创建了一个函数来确定选定的标签栏索引。
当我打开应用程序时,索引 0 是自动选择的并且运行良好。当我向下滚动并点击标签栏索引时,视图会自动滚动到顶部。当我转到索引 1 并在那里触发滚动时会出现问题。它以某种方式从我的第一个标签栏项目中完全删除了自动滚动。
在没有自动滚动的情况下选择其他标签栏项目根本不会影响索引 0。
主页(索引 0)
func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
let tabBarIndex = tabBarController.selectedIndex
if tabBarIndex == 0 {
self.collectionView?.setContentOffset(CGPoint(x: 0, y: -10), animated: true)
}
}
Run Code Online (Sandbox Code Playgroud)
用户(索引 1)
func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
let tabBarIndex = tabBarController.selectedIndex
if tabBarIndex == 1 {
self.tableView?.setContentOffset(CGPoint(x: 0, y: 0), animated: true)
}
}
Run Code Online (Sandbox Code Playgroud) 如何使用“hidesBottomBarWhenPushed”正确隐藏 UITabBarController 的 tabBar?
视图控制器A:
hidesBottomBarWhenPushed = true
Run Code Online (Sandbox Code Playgroud)
这成功地隐藏了 tabBar,但即使从 viewControllerB 弹出 viewControllerA,它也会永久隐藏。
有没有其他人注意到以编程方式更改标签栏高度在 iOS 13 中不起作用?有没有人有解决方法?相同的代码在 iOS 11 和 12 中完美运行,但标签栏在 iOS 13 中没有调整大小。谢谢