标签: uinavigationcontroller

导航栏后面出现快速黑色背景

!注意:我见过一些其他问题报告有关出现黑条的问题,但该问题不是重复的(如果我错了,请纠正我),对我来说,当我执行推送转场时,会出现类似黑色视图的内容。黑条问题的解决方案都不适合我(区别:我出现了黑色视图)。我在故事板中使用了标准的“show”segue。以下是viewDidLoad我的第一个 vc中的代码UIViewController(此 vc 执行到我的第二个 vc 的转接):

if #available(iOS 11.0, *) {
    navigationController!.navigationBar.prefersLargeTitles = false
}

mapView.delegate = self

locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
Run Code Online (Sandbox Code Playgroud)

这是我的第二个 vc 中的代码viewDidLoad(segue 通向此 vc):

if #available(iOS 11.0, *) {
    navigationController!.navigationBar.prefersLargeTitles = true
}
Run Code Online (Sandbox Code Playgroud)

他们都使用相同的navigationController. 对于我的第一个 vc,我想要 navBar preferresLargeTitles = false,对于我的第二个 vc,我想要 navBar,preferresLargeTitles = true这就是我在viewDidLoad方法中所做的事情。MapKit关于和 的5 行CoreLocation不应导致这种效果,但我不知道为什么会出现这个黑色视图,所以我留下了这些代码行。当执行转场时,如何删除出现在导航栏后面的黑色视图?(当segue完成后黑色消失)(右上角的黑色是困扰我的)

uinavigationbar uinavigationcontroller segue uistoryboardsegue swift

2
推荐指数
1
解决办法
2432
查看次数

UINavigationController 向下滑动手势检测

UINavigationController 以模态形式呈现为表单,可以向下滑动以关闭。这个手势是 iOS 原生的,不是我的。问题出在 iOS 13 上,它在被关闭后不会触发父视图控制器中的 viewWillAppear 。所以我需要一种方法来知道视图控制器正在被解除或被系统手势解除。在这种情况下,如何检测视图控制器的解除?

uiviewcontroller uikit uinavigationcontroller ios swift

2
推荐指数
1
解决办法
2625
查看次数

在没有 UINavigationController 的情况下如何使用 UISearchController?

当视图控制器未嵌入 UINavigationController 中时,我不明白如何使用 UISearchController 。

为了说明我的意思,请尝试下载此代码:https://developer.apple.com/documentation/uikit/view_controllers/displaying_searchable_content_by_using_a_search_controller

然后,删除导航控制器并使表格搜索场景成为初始视图控制器。该表仍然正常工作,但搜索控制器不显示。

有没有办法修改该代码,以便您可以使用 UISearchController 而无需将其嵌入导航控制器中?我在文档中没有看到任何需要 UINavigationController 的内容。所有与此相关的堆栈溢出问题都告诉您单独使用 UISearchBar。我对使用 UISearchController 特别感兴趣。

uikit uinavigationcontroller ios swift uisearchcontroller

2
推荐指数
1
解决办法
1305
查看次数

如何在 iOS 的导航中制作带有徽标和文本的自定义导航栏?

由于我来自混合应用程序背景,我想在 iOS 中实现一个包含徽标和文本的 UI。下面是一个蓝色条,其中包含“返回”和“注册”作为标题。单击返回时,它将转到上一个控制器。我怎样才能实现这个用户界面?我尝试使用下面给定的代码:但我不确定如何进一步进行。

func addNavBarImage() {
        let navController = navigationController!
        let image = UIImage(named: "logo-signIn6.png") //Your logo url here
        let imageView = UIImageView(image: image)
        let bannerWidth = navController.navigationBar.frame.size.width
        let bannerHeight = navController.navigationBar.frame.size.height
        let bannerX = bannerWidth / 2 - (image?.size.width)! / 2
        let bannerY = bannerHeight / 2 - (image?.size.height)! / 2
        imageView.frame = CGRect(x: bannerX, y: bannerY, width: bannerWidth, height: bannerHeight)
        imageView.contentMode = .scaleAspectFit
        navigationItem.titleView = imageView
    }
Run Code Online (Sandbox Code Playgroud)

下面是我想要实现的 UI 图像。在此输入图像描述

iphone xcode uinavigationcontroller ios swift

2
推荐指数
1
解决办法
6022
查看次数

iOS 自定义导航栏后退按钮标题在点击时消失

你好 StackOverflow 社区,

我有一个相当奇怪的情况,导航控制器的导航栏上的自定义后退按钮在交互时消失。

一些附加信息是我的代码没有使用 Storyboard,而是使用 UIKit - 包括 UI 在内的所有内容都是以编程方式构建的。

这是我的设置:

  • 我首先创建一个自定义 UINavigationController 子类,以抽象出所有与导航控制器相关的自定义项

  • 在这个子类中,我有一个被调用的方法来自定义后退按钮的外观

private func customizeBackButton() {
    let backImage = UIImage(named: "BackButton")?.withRenderingMode(.alwaysOriginal)
    navigationBar.backIndicatorImage = backImage
    navigationBar.backIndicatorTransitionMaskImage = backImage
    
    UIBarButtonItem.appearance().setTitleTextAttributes([
      NSAttributedString.Key.foregroundColor: UIColor.panoStoryYellow,
      NSAttributedString.Key.font: UIFont(name: "Montserrat-SemiBold", size: 15)!
    ], for: .normal)
}
Run Code Online (Sandbox Code Playgroud)
  • 上面的自定义给出了以下结果,这正是我想要的结果,图库是我上一个屏幕的标题

UINavigationController 自定义后退按钮

  • 当我点击箭头所在的后退按钮的最左边缘时,该按钮正常工作。但是,如果我点击后退按钮的标签部分(图库文本所在的位置),文本就会消失并使用户保持在同一屏幕上。

UINavigationController UINavigationBarButton后退按钮消失

当我在标签消失后点击后退箭头时,它会起作用并将我带回到上一个屏幕,但是,为什么会发生这种消失呢?

我尝试过什么 我尝试过许多关于堆栈溢出的建议,例如:

  • 确保我的代码中没有任何行显式隐藏后退按钮
  • 随时检查上一屏幕的标题是否为空字符串

我可以确认这些不是问题,因为我有有效的标题并且从不隐藏后退按钮。

以下是我在确定它们都不适合我的情况之前检查过的一些资源,我在这里提出了问题:

UINavigationController 后退按钮不可见,但可以使用

UINavigationController的后退按钮消失了?

使用自定义后退按钮后导航标题消失

按下后退按钮时,上一屏幕上的导航标题消失

连续推送 ViewController 时缺少导航或后退按钮的标题

关于为什么这个后退按钮文本消失的任何想法?

uikit uinavigationcontroller uibarbuttonitem ios swift

2
推荐指数
1
解决办法
795
查看次数

为什么initWithRootViewController不保留传递给它的viewController类?

我有一个名为SourceListViewController的自定义viewController,我将它添加到UINavigationController中,然后将其视图添加到iphone App的窗口中.在将SourceListViewController传递给UINavigationController之后,我发布了sourceListViewController.

SourceListViewController *sourceListVC = [[SourceListViewController alloc] initWithNibName:@"SourceListViewController" bundle:nil];
UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewController:sourceListVC] autorelease];
[sourceListVC release];
Run Code Online (Sandbox Code Playgroud)

当我这样做时,应用程序会在视图加载到手机后崩溃.当我注释掉最后一行时,应用程序正常工作.是不是initWithRootViewController应该保留sourceListVC的副本?

iphone uinavigationcontroller

1
推荐指数
1
解决办法
2844
查看次数

将View Controller推入导航控制器

有时,当我将ViewController推入导航控制器时,不会调用View Controller的viewDidLoad()方法.这导致我的应用程序崩溃.我将不胜感激任何帮助.

我忘记提到我在将其推入导航控制器之前从笔尖加载视图.

谢谢,莎拉

iphone cocoa-touch uinavigationcontroller

1
推荐指数
1
解决办法
9509
查看次数

TabBarController和NavigationController的问题

我尝试使用的标签...什么都试过叫各的UIViewController内一个UINavigationController ...阅读每一篇文章编程做的UITabBarController ...但香港专业教育学院的教程100%发现使用在UITableViewControllers ...这里是应用程序代表:

//
//  mluThunderCamAppDelegate.m
//  mluThunderCam
//
//  Created by Paulo Ferreira on 11/9/09.
//  Copyright MobileLifeUtils.com 2009. All rights reserved.
//

#import "mluThunderCamAppDelegate.h"

@implementation mluThunderCamAppDelegate

@synthesize window, tbcMain;


- (void)applicationDidFinishLaunching:(UIApplication *)application {    
    // Override point for customization after application launch
 UINavigationController *ncLocal;
 mluThunderCam *vcThunderCam = [[mluThunderCam alloc] init];
 ncLocal = [[UINavigationController alloc] initWithRootViewController:vcThunderCam];
 [ncLocal release];

 mluThunderCamPreferences *vcThunderCamPreferences = [[mluThunderCamPreferences alloc] init];
 ncLocal = [[UINavigationController alloc] initWithRootViewController:vcThunderCamPreferences];
 [ncLocal release];

 NSArray *aViewControllers = [[NSArray alloc] initWithObjects:vcThunderCam, vcThunderCamPreferences, nil]; …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uitabbarcontroller uinavigationcontroller

1
推荐指数
1
解决办法
946
查看次数

使用代码在UINavigationcontroller中触发按钮

如何在我的导航控制器中获得一个级别?文档对我没有帮助.

[self.navigationController popToRootViewControllerAnimated:YES];
Run Code Online (Sandbox Code Playgroud)

弹出到根(如它所说).

[self.navigationController dismissModalViewControllerAnimated:YES];
Run Code Online (Sandbox Code Playgroud)

也没用.

谢谢你的帮助!

iphone uinavigationcontroller

1
推荐指数
1
解决办法
1082
查看次数

尝试在Tabbar应用程序的UINavigation栏下添加迷你UIToolbar

我有一个UITabBar带有嵌入式导航控制器的应用程序,它正在加载表视图.

我想在导航栏下面添加一个迷你工具栏,带有一个分段控件,可以按组或按名称对表数据进行排序.

我已尝试使用界面构建器,尝试将工具栏添加到表视图控制器和导航控制器,将工具栏连接到文件所有者,但无论我尝试什么工具栏都不会显示.

我已尝试在代码中使用创建工具栏UITableViewController,但工具栏随后滚动表格.

我试图取消隐藏导航控制器中的工具栏...

[self.navigationController setToolbarHidden:NO];
Run Code Online (Sandbox Code Playgroud)

并setItems使用数组添加按钮,但我只能在标签栏正上方找到一个空白工具栏.

任何有关这方面的帮助将不胜感激.

谢谢.

iphone uisegmentedcontrol uitoolbar uinavigationcontroller uitabbar

1
推荐指数
1
解决办法
2259
查看次数