标签: uinavigationcontroller

如何在使用故事板时继承Navigation Controller?

我在界面构建器中使用故事板使用Xcode菜单'Editor ... Embed in ... Navigation Controller'.

似乎在iOS 6中你必须将UINavigationController子类化为允许所有方向

- (NSUInteger)supportedInterfaceOrientations {
    return (UIInterfaceOrientationMaskAll   );
}
Run Code Online (Sandbox Code Playgroud)

但是,如何将UINavigationController与故事板应用程序子类化,因为代码中没有对它的引用?

iphone storyboard uinavigationcontroller subclassing uiinterfaceorientation

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

向UINavigationController添加自定义视图

我有一个UINavigationController当事件被触发时我需要一个自定义UIView出现在它下方NavigationBar,但不会阻碍当前ViewController.我还需要在执行UIView控制器时弹出/推送持久性.

 -----------------
|   Status Bar    |
 -----------------
|     Nav Bar     |
 -----------------
|   Custom View   |
 -----------------
|                 |
| View Controller |
|                 |
 -----------------
Run Code Online (Sandbox Code Playgroud)

我正在CustomView (UIView)设置框架,如:

- (id)initWithNavigationController:(UINavigationController *)navController {
    self.navController = navController;
    return [self init];
}

- (id)init
{
    CGRect viewFrame = self.navController.view.frame;

    return [self initWithFrame:CGRectMake(viewFrame.origin.x,
                                      self.navController.navigationBar.frame.origin.y + self.navController.navigationBar.frame.size.height,
                                      viewFrame.size.width,
                                      40.0)];
}
Run Code Online (Sandbox Code Playgroud)

这是怎么回事?

uinavigationcontroller ios

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

隐藏UINavigationBar但仍显示状态栏

如何通过不隐藏我的应用程序中的状态栏来隐藏导航栏?当我尝试[self.navigationController.navigationBar setHidden:YES];它时也隐藏状态栏.我需要像这样显示状态栏:

在此输入图像描述

我需要先隐藏一个可见的导航栏,使状态栏仍然可见,我还有一个视图,我需要移动到状态栏下方,但是当我设置框架时,视图的位置就像导航栏仍然存在位置为0,0.

我将状态栏设置为:

[[UIApplication sharedApplication] setStatusBarHidden:NO];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
Run Code Online (Sandbox Code Playgroud)

xcode uinavigationcontroller ios

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

Swift - 导航视图控制器不出现标题

我有一个导航视图控制器,在操作时将一个segue发送到标签栏视图控制器.由于此segue,选项卡式视图控制器继承导航栏.我正在尝试将标题应用于附加到标签栏视图控制器的我的一个视图控制器,但是通过代码设置标题对我来说不起作用.有谁知道原因可能是什么?

这是我的故事板的图片:

storuboard

带有注销按钮的视图控制器是我试图在导航栏(代码)中设置标题的地方:

import UIKit

class ProfileSettingsViewController: UIViewController {

    override func viewWillAppear(animated: Bool) {

        self.navigationItem.title = "Profile Settings"

    }

    override func viewDidLoad() {
        super.viewDidLoad()

        self.navigationItem.leftBarButtonItem = nil


    }



    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }



    @IBAction func logoutButton(sender: AnyObject) {

        PFUser.logOut()
        var currentUser = PFUser.currentUser()
        self.performSegueWithIdentifier("userLoggedOut", sender: self)
        self.navigationController?.setNavigationBarHidden(self.navigationController?.navigationBarHidden == false, animated: true)

    }

}
Run Code Online (Sandbox Code Playgroud)

嵌入导航控制器的视图控制器触发到标签栏控制器的segue:

import UIKit

class UserRegistrationViewController: UIViewController {


    func displayAlert(title:String, error:String) {

        var alert = UIAlertController(title: title, message: …
Run Code Online (Sandbox Code Playgroud)

xcode uinavigationcontroller ios xcode-storyboard swift

8
推荐指数
5
解决办法
2万
查看次数

具有大标题跳跃的后退按钮动画

我们有两个UIViewController用UINavigationController.

在viewWillAppear(_ animated: Bool)我们做的第一个介绍VC里面:

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        if #available(iOS 11.0, *) {
            navigationController?.navigationBar.prefersLargeTitles = true
            navigationController?.navigationItem.largeTitleDisplayMode = .always
        }
 ....
Run Code Online (Sandbox Code Playgroud)

在第二个VC的内部我们拒绝了内部的行为viewWillAppear(_ animated: Bool):

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    if #available(iOS 11.0, *) {
        navigationController?.navigationBar.prefersLargeTitles = false
    }
...
Run Code Online (Sandbox Code Playgroud)

到第二个VC的过渡动画是平滑的,而点击自动生成的后退按钮会导致导航控制器标题创建一个奇怪的jump to large title而不是正常的grow to large title动画,就像在消息应用程序中那样.

如果我点击标签栏图标作为"后退"操作,它会执行正确的过渡动画.

知道什么可能导致该问题或我如何解决它?

animation uiviewcontroller uinavigationcontroller ios

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

iOS 13 中的条形按钮色调颜色

在 iOS 13 中,他们改变了导航栏颜色的操作方式。现在他们使用 UINavigationBarAppearance 和 UIBarButtonItemAppearance 来自定义导航栏,以及 standardAppearance 和 scrollEdgeAppearance。

我正在寻找一种方法来为standardAppearance 和scrollEdgeAppearance 设置不同的导航栏色调颜色。或者能够为每个外观更改条形按钮图标颜色。

        //set the standard nav bar appearance
        let navBarAppearance = UINavigationBarAppearance()
        navBarAppearance.configureWithOpaqueBackground()
        navBarAppearance.titleTextAttributes = [.foregroundColor: UIColor.white]
        navBarAppearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white]
        navBarAppearance.backgroundColor = UIColor.mainAppColorForNavBar

        //set bar button appearance
        let buttonAppearance = UIBarButtonItemAppearance()
        buttonAppearance.normal.titleTextAttributes = [.foregroundColor : UIColor.white]
        navBarAppearance.buttonAppearance = buttonAppearance

        UINavigationBar.appearance(whenContainedInInstancesOf: [UINavigationController.self]).standardAppearance = navBarAppearance



        //set the scroll edge nav bar appearance
        let scrollNavBarAppearance = UINavigationBarAppearance()
        scrollNavBarAppearance.configureWithOpaqueBackground()
        scrollNavBarAppearance.titleTextAttributes = [.foregroundColor: UIColor.label]
        scrollNavBarAppearance.largeTitleTextAttributes = [.foregroundColor: UIColor.label]

        //set bar button appearance …
Run Code Online (Sandbox Code Playgroud)

uinavigationcontroller ios swift ios13

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

如何在颤动中弹出到特定屏幕

我推了四屏 ScreenOne >> ScreenTwo >> ScreenThree >> ScreenFour

我现在在ScreenFour,我想回到ScreenTwo

在 Swift 中它是这样工作的:

if let viewControllers: [UIViewController] = self.navigationController!.viewControllers {
    for vc in viewControllers
    {
        if (vc is SecondViewController)
        {
            self.navigationController!.popToViewController(vc, animated: true)
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我如何在颤振中执行此操作。

请给出解决方案,谢谢。

uinavigationcontroller ios dart swift flutter

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

NavigationView 标题中的 SwiftUI 多行文本

我怎么能让这个标题多行?

在此处输入图片说明

我曾尝试将标题文本设置为多行,甚至使用 allowedThigtening(flag: Bool) 对其进行配置,但这些选项均无效。

当前代码在这里:

import SwiftUI

struct DistributionCentersView: View {
    var dcViewModel = DistributionCenterViewModel()
    @State private var pickedSelectedData = 0
    @State private var searchTerm = ""

    init() {
        //...

    }

    var body: some View {
        NavigationView {
            VStack {
                VStack {
                    Picker(selection: $pickedSelectedData, label: Text("")){
                        Text("All").tag(0)
                        Text("Nevial").tag(1)
                        Text("Net power").tag(2)
                    }.pickerStyle(SegmentedPickerStyle())
                        .foregroundColor(Color.white)
                        .background(Color(#colorLiteral(red: 0.03921568627, green: 0.03921568627, blue: 0.03921568627, alpha: 1)))
                    SearchBar(text: $searchTerm)
                }
                .padding(.leading, 16)
                .padding(.trailing, 16)
                .padding(.top, 34)

                List {
                    ForEach (dcViewModel.distribuitionCenters){ dc in
                        ZStack { 
                            DistributionCenterCell()
                                .listRowInsets(EdgeInsets(top: …
Run Code Online (Sandbox Code Playgroud)

uinavigationcontroller ios swift navigationview swiftui

8
推荐指数
2
解决办法
2841
查看次数

SwiftUi Navigation Bar Button 在进入第三个 View (Controller) 后消失

我对 SwiftUi 有一个大问题。真正简单的 NavigationView 层次结构中的“后退按钮”在第三个视图中消失了。如果我再看一个视图,返回按钮又出现了,我可以返回。

我搜索了 3 小时,但只找到了这个SwiftUI:单击 NavigationLink 时后退按钮消失

显然这并不能解决我的问题。

谢谢你的帮助!

uinavigationcontroller swiftui

8
推荐指数
5
解决办法
1698
查看次数

如何从 SwiftUI 推送到现有的 UINavigationController 堆栈?

我们正在推动SwiftUI嵌入在土地中的视图,UIHostingViewController如下UIKit所示:

首先制作UIViewController:

    func hostingController() -> UIViewController {
    let swiftUIView = swiftUIView(viewModel: viewModel(data: [Data, Data, Data]))
    return UIHostingController(rootView: swiftUIView)
}
Run Code Online (Sandbox Code Playgroud)

然后将其压入UINavigationView堆栈:

[self.navigationController pushViewController:hostingViewController animated:YES];
Run Code Online (Sandbox Code Playgroud)

这让我们进入了SwiftUI环境。但是,如果我们的SwiftUI环境有自己的带有NavigationView和的导航堆栈NavigationLink,则原始navigationBar的后退按钮只能导航回原始呈现UIViewController。

有没有办法将SwiftUI嵌入的视图推NavigationView送到现有UINavigationController堆栈上?

到目前为止,我们唯一的想法是UIHostingViewController为每个新SwiftUI屏幕创建一个新屏幕,并通过某种委托方法将其推送到堆栈上。

我们正在寻找的是这样的:

UINavigationStack: [UIViewController -> UIViewController -> SwiftUIView -> SwiftUIView]
Run Code Online (Sandbox Code Playgroud)

中的后退<箭头navigationBar将按预期运行。

如果我们可以进一步澄清,请告诉我们!

uinavigationcontroller swift swiftui swiftui-navigationlink swiftui-navigationview

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