【发布时间】:2012-12-11 04:45:33
【问题描述】:
我希望能够将右侧导航栏按钮更改为具有名称和操作的不同按钮。
举个例子:
btnOpenImage 被按下,rightNavButton1 变为 rightNavButton2
【问题讨论】:
-
我理解错了吗?这就像设置 rightNavigationItem 一样????这里有什么问题?
标签: iphone button navigation switch-statement
我希望能够将右侧导航栏按钮更改为具有名称和操作的不同按钮。
举个例子:
btnOpenImage 被按下,rightNavButton1 变为 rightNavButton2
【问题讨论】:
标签: iphone button navigation switch-statement
-(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];
}
【讨论】:
试试这个:
[btnOpenImage addTarget:self
action:@selector(aMethod)
forControlEvents:UIControlEventTouchDown];
- (void)aMethod
{
[rightNavButton1 setTitle: @"rightNavButton2" forState: UIControlStateNormal];
}
【讨论】: