iphone - 按下按钮时更改导航按钮项目

标签 iphone button navigation switch-statement

我希望能够将右侧导航栏按钮更改为具有名称和操作的不同按钮。

举个例子:

btnOpenImage 被按下,rightNavButton1 更改为 rightNavButton2

最佳答案

    -(IBAction) btnOpenImage_Clicked:(id)sender{

//1. IF buttons are UIBarButtonItem then use bellow code
                  // This bellow line for Change the action(Target)
                 [rightNavButton1 setAction:@selector(rightNavButton2_Clicked)]; 

                 //This bellow line For Change  the Title
                 [rightNavButton1 setTitle:@"rightNavButton2_Clicked"]; 

//OR 2. IF buttons are UIButton then use bellow code

                // This bellow line for Change the action(Target)
                [rightNavButton1 addTarget:self action:@selector(rightNavButton2_Clicked) forControlEvents:UIControlEventTouchUpInside];

                //This bellow line For Change  the Title
                [rightNavButton1 setTitle: @"rightNavButton2" forState: UIControlStateNormal];
    }

关于iphone - 按下按钮时更改导航按钮项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13813797/

相关文章:

ios - 如何首先在容器页面 View Controller 内实例化任何 View ?

iphone - 来自远程服务器的 obj-C、Json + Coredata - 没有本地数据库/数据库,最佳方法?

HTML CSS 隐形按钮

navigation - MvvmCross 5.x 的 MvvmCross 侧边栏导航

iphone - 当前时间在 HH :MM:SS am/pm format?

ios - 如何根据内容动态设置 tableview 的高度,但它应该与底部按钮保持最小距离?

c# - 禁用点击按钮事件c#

javascript - 如果选中复选框,则触发事件javascript

ios - 从表 XIB 识别并导航到 Storyboard View Controller

html - 如何阻止导航栏列表改变位置?