gpt4 book ai didi

iphone - UIBarButtonItem 操作不起作用。为什么?

转载 作者:行者123 更新时间:2023-12-03 20:16:03 26 4
gpt4 key购买 nike

谢谢大家。我找到了真正有效的代码。它看起来像:

- (void)viewDidLoad {
[super viewDidLoad];

UIButton* infoButton = [UIButton buttonWithType: UIButtonTypeInfoLight];
[infoButton addTarget:self action:@selector(settingsClick) forControlEvents:UIControlEventTouchDown];

UIBarButtonItem* theSettingsButton =[[UIBarButtonItem alloc]initWithCustomView:infoButton];

[self.toolbar setItems:[NSArray arrayWithObjects:theSettingsButton,nil]];

[theSettingsButton release];
}

最佳答案

这有效:

- (void)viewDidLoad {
[super viewDidLoad];

UIBarButtonItem *theSettingsButton = [[[UIBarButtonItem alloc]
initWithTitle:@"Settings" style:UIBarButtonItemStyleBordered
target:self action:@selector(settingsClick)] autorelease];

}

-(void)settingsClick
{
NSLog(@"Hello");
}

您尚未关闭 viewDidLoad 方法。

关于iphone - UIBarButtonItem 操作不起作用。为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6370578/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com