gpt4 book ai didi

iphone - 将按钮添加到底部工具栏

转载 作者:行者123 更新时间:2023-11-29 04:50:59 25 4
gpt4 key购买 nike

我有以下代码:

self.shareButton=[[UIButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 35, 35)];
[shareButton setBackgroundColor:[UIColor blueColor]];
[shareButton setBackgroundImage:[UIImage imageNamed:@"share_button"] forState:UIControlStateNormal];
[shareButton setBackgroundImage:[UIImage imageNamed:@"share_button_pressed"] forState:UIControlStateHighlighted];
[shareButton addTarget:self action:@selector(shareButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.navigationController setToolbarItems:[NSArray arrayWithObject:shareButton] animated:YES];

为什么我看不到工具栏按钮?有什么问题吗?

最佳答案

meggar所说的可能就是正确的答案。尝试这样做。

--更新--由于问题仍然存在,我更新了示例,将 set 调用移至 View Controller 而不是导航 Controller 。

UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:shareButton];
[self setToolbarItems:[NSArray arrayWithObject:barButtonItem] animated:YES];
[barButtonItem release];

关于iphone - 将按钮添加到底部工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8853910/

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