简体   繁体   中英

change BarButton item identifier on code

I have a bar button item on StoryBoard,its identifier is Play, How can I change this bar button's identifier on code?

- (IBAction)play:(UIBarButtonItem *)sender {
  // For example,when I touch this button,
  // it change its Identifier to Stop
}

use UIButton 's tag features

using UIButton outlet set tag for play like testButton.tag = 1;

then in

- (IBAction)play:(UIBarButtonItem *)sender {
    if (sender.tag == 1) {
       testButton.tag = 2;
    } else if (sender.tag == 2) {
       testButton.tag = 1;
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM