标签: uinavigationcontroller

默认导航栏高度ios

在我的一个控制器中我使用自定义工具栏,我想在ios中获得默认工具栏(导航栏)的高度.我用过宏#define NAVBAR_HEIGHT self.navigationController.navigationBar.frame.size.height.

但是,当控制器没有嵌入导航堆栈时,宏返回零.

我不想使用44的常量,因为它可能在其他Apple设备上有所不同.

对于标签栏,我使用:

+(CGFloat)getTabBarHeight{

    UITabBarController *tabBarController = [UITabBarController new];
    CGFloat tabBarHeight = tabBarController.tabBar.frame.size.height;
    return tabBarHeight;
}
Run Code Online (Sandbox Code Playgroud)

有没有这样的片段,所以我可以返回导航控制器工具栏的值?

uinavigationcontroller ios

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

IOS:推送segue后导航栏消失

stroyboard

每次我执行我的节目(推)时,文章VC都没有显示其导航栏以显示标题或后退按钮.我还检查了导航控制器是否有标题,因为这似乎是某些情况的解决方案.执行segue的类只发送信息.类别是枚举.

在此输入图像描述

uinavigationbar uinavigationcontroller uinavigationitem ios swift

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

UISearchController不要将viewcontroller推到UISearchController的下方

自动呈现UISearchController和自己呈现搜索控制器之间的行为有所不同。

@implementation MyViewComtroller

// click search barbutton on right of navigationBar
- (void)searchAction:(id)sender {
    ArticleSearchViewController *searchResultsController = [[ArticleSearchViewController alloc] init];
    UISearchController *searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController];
    searchController.searchResultsUpdater = searchResultsController;
    searchController.searchBar.delegate = searchResultsController;
    searchController.delegate = searchResultsController;
    searchController.hidesNavigationBarDuringPresentation = NO;
    [self presentViewController:searchController animated:YES completion:nil];
}

@end

@implementation ArticleSearchViewController

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    ArticleDetailController * articleDetailController = [ArticleDetailController new];
   [(UINavigationController *)self.presentingViewController pushViewController:articleDetailController animated:YES];
}

@end
Run Code Online (Sandbox Code Playgroud)

推送操作发生在UISearchController下面。

uinavigationbar uinavigationcontroller uisearchbar ios uisearchcontroller

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

导航栏为白色,而isTranslucent = false

我有一个主导航控制器,在其中设置背景颜色

 override func viewDidLoad() {
    super.viewDidLoad()

    self.navigationBar.backgroundColor = UIColor.blue
    self.navigationBar.isTranslucent = false
}
Run Code Online (Sandbox Code Playgroud)

但是,在那种情况下,我的导航栏会变成完全白色。当我将isTranslucent设置为true时,我的导航栏将变为透明,但这实际上不是我所需要的。我只想有蓝色的导航栏。

以防万一在我的导航控制器中

override var preferredStatusBarStyle: UIStatusBarStyle{ return .lightContent }
Run Code Online (Sandbox Code Playgroud)

并在AppDelegate中设置色调颜色

UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]
Run Code Online (Sandbox Code Playgroud)

评论tintColor也没有帮助我。

这是我的“蓝色”导航栏

objective-c uinavigationcontroller ios swift

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

防止UINavigationController在iOS 11中使用偏移量向上过渡动画?

我正在使用iOS 9目标将应用程序从iOS 10更新到iOS 11,当涉及导航栏时,这会发生在每个segue动画上.

动画以小于它应该处于的高度的小偏移开始,然后在视图完成动画时移动到适当的高度.

我没有对导航控制器做任何特别的事情,它发生在应用程序中的每一个.如果我以编程方式隐藏导航栏,则转换正常进行动画处理.

uinavigationcontroller ios ios11

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

当前视图与UINavigationController的导航栏重叠

我正在以编程方式为我的应用程序设计一个注册页面视图,用户可以在其中输入自己的图像和一些信息。

在我的LoginController中,创建一个UINavigationController并带有我的RegisterController的rootviewcontroller,然后将其显示。

func handleRegisterButtonClicked() {
    let registerController = RegisterController()
    let navController = UINavigationController(rootViewController: registerController)
    present(navController, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)

现在,我为他们添加了图片,以供单击以上传他们的照片。我希望此图片始终在导航栏下方显示30px,但要重叠在导航栏下方,从屏幕顶部显示30px:

肖像导向 风景导向

class RegisterController: UIViewController {
...
func setupViews() {
    profilePic.topAnchor.constraint(equalTo: view.topAnchor, constant: 30).isActive = true
}
Run Code Online (Sandbox Code Playgroud)

有没有一种方法可以向profilePic添加约束,以便将其锚定在导航栏的底部(纵向和横向)?

layout uinavigationbar uinavigationcontroller ios swift

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

当按下导航栏的内置后退按钮时,弹出到根视图控制器

每当在顶部视图控制器上按下后退按钮时,我都想返回到特定的视图控制器,而不是先前的视图控制器。我希望有一种方法可以某种方式覆盖后退按钮的功能。

编辑:

我得到这个工作:

self.navigationController?.popToRootViewController(animated: true)

唯一的问题是,在对其进行动画处理时,它会将中间视图控制器显示为根目录。

uinavigationbar uinavigationcontroller ios swift

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

导航栏按钮和未迅速显示的项目3

在此处输入图片说明

正在以编程方式快速使用导航栏,但无法在导航栏中显示栏按钮项,这是我所做的代码

override func viewDidLoad() {
        super.viewDidLoad()

  let navBar: UINavigationBar = UINavigationBar(frame: CGRect(x: 0, y: 0, width: 420, height: 65))
        self.view.addSubview(navBar)

        navBar.backgroundColor = hexStringToUIColor("4DC8BD")

        let navigationItem = UINavigationItem()

       self.title = "Transport APP"

        let btn1 = UIButton(type: .custom)
        btn1.setImage(UIImage(named: "Menu1"), for: .normal)
        btn1.frame = CGRect(x: 30, y: 30, width: 30, height: 30)
        btn1.addTarget(self, action: #selector(HomeViewController.menubuttonclick(_:)), for: .touchUpInside)
        let item1 = UIBarButtonItem(customView: btn1)


         self.navigationItem.setRightBarButtonItems([item1], animated: true)

}

    @IBAction func menubuttonclick(_ sender:UIBarButtonItem )
    {

        print("this menu button click")

    }
Run Code Online (Sandbox Code Playgroud)

我可以尝试多种方法,但无法获得如何在导航栏中显示显示栏按钮项的结果,

uinavigationcontroller ios swift

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

isBeingPresented值不一致

我以模态方式呈现了一个带有ViewController的NavigationController.

在ViewController中我可以看到这self.navigationController.isBeingPresented是真的.

但是,如果我现在在模态呈现的NavigationController上推送一个新的ViewController并弹回到原始的ViewController,则同一个check的调用isBeingPresented返回false.

文档很少但我不能真正解释这种不一致,除了它可能是一个错误?

uikit uinavigationcontroller ios

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

将用户重定向到特定的ViewController-Swift 4

删除地点后,我尝试将用户重定向到正确的页面。

在此处输入图片说明

navigationController?.popToRootViewController(animated: true)
Run Code Online (Sandbox Code Playgroud)

如果我想重定向到根目录,这将起作用。

navigationController?.popViewController(animated: true)
Run Code Online (Sandbox Code Playgroud)

如果我想重定向到上一个,这将起作用

但就我而言,我想重定向到特定页面而不是根目录或上一个页面。

在iOS中如何去做这样的事情?

uinavigationbar uinavigationcontroller ios segue swift

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