在iOS-7中按需隐藏和显示左侧导航栏按钮 [英] hide and show left navigation bar button on demand in iOS-7

查看:176
本文介绍了在iOS-7中按需隐藏和显示左侧导航栏按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用故事板添加了我的左侧导航栏按钮。但我希望它在我第一次加载屏幕时隐藏。然后在回应别的东西时,我想要它展示。导航栏有一个隐藏后退按钮的方法。但是没有隐藏/显示左键的方法。这样做有简单的方法吗?或者我必须使用两种方法:隐藏方法创建一个空按钮,显示方法创建正确的按钮?有问题的按钮只是iOS提供的添加模板(这样可以轻松地使用故事板中的那个而不是创建我自己的模板)。

I added my left navigation bar button using the storyboard. but I want it to hide when I first load the screen. And then in response to something else, I want it to show. The navigation bar has a method for hiding the back button. But there is no method for hiding/showing the left button. Is there a simple way for doing this? Or do I have to use two methods: the hiding method creates an empty button and the showing method creates the correct button? The button in question is just the Add template that iOS provides (which makes it easy to just use the one in the storyboard than to create my own).

推荐答案

以下是我解决的方法

-(void) hideAndDisableRightNavigationItem
{
    [self.navigationItem.rightBarButtonItem setTintColor:[UIColor clearColor]];
    [self.navigationItem.rightBarButtonItem setEnabled:NO];
}

-(void) showAndEnableRightNavigationItem
{
    [self.navigationItem.rightBarButtonItem setTintColor:[UIColor blackColor]];
    [self.navigationItem.rightBarButtonItem setEnabled:YES];
}

这篇关于在iOS-7中按需隐藏和显示左侧导航栏按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆