0
我已經創建了基於UIButton
的UIBarButtonItem
。我如何在事件處理程序中獲得UIBarButtonItem
(!!!)的引用?從UIButton獲取對UIBarButtonItem的引用?
UIButton *brigthnessButton = [[UIButton alloc]
initWithFrame:CGRectMake(0, 0, 32, 32)];
[brigthnessButton setImage:newImage forState:UIControlStateNormal];
forState:UIControlStateSelected];
[brigthnessButton addTarget:self action:@selector(createShortcut:)
forControlEvents:UIControlEventTouchUpInside];
shortCut = [[UIBarButtonItem alloc] initWithCustomView:brigthnessButton];
- (void)createShortcut:(UIButton *)button {
UIBarButtonItem *b = ???
}
難道你真的確定你需要在一個的UIBarButtonItem的UIButton?用戶也可以直接點擊UIBarButtonItem。 – idmean 2014-08-27 12:33:21