UIBarButtonItem: target-action not working?

后端 未结 11 933
无人及你
无人及你 2020-12-01 08:47

I\'ve got a custom view inside of a UIBarButtonItem, set by calling -initWithCustomView. My bar button item renders fine, but when I tap it, it doe

11条回答
  •  半阙折子戏
    2020-12-01 09:35

    Here is how I make it work:

    UIButton* infoButton = [UIButton buttonWithType: UIButtonTypeInfoLight];
    [infoButton addTarget:self action:@selector(displayAboutUs) forControlEvents:UIControlEventTouchDown];
    
    UIBarButtonItem* itemAboutUs =[[UIBarButtonItem alloc]initWithCustomView:infoButton];
    …
    

提交回复
热议问题