2

右のナビゲーション バー ボタンを、名前とアクションを持つ別のボタンに変更できるようにしたいと考えています。

例として:

btnOpenImage が押され、rightNavButton1 が rightNavButton2 に変更されます

4

2 に答える 2

2
    -(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];
    }
于 2012-12-11T05:11:59.397 に答える
1

これを試して:

[btnOpenImage addTarget:self 
               action:@selector(aMethod)
     forControlEvents:UIControlEventTouchDown];

- (void)aMethod
{
   [rightNavButton1 setTitle: @"rightNavButton2" forState: UIControlStateNormal];

}
于 2012-12-11T04:55:25.830 に答える