gpt4 book ai didi

ios - objective-c 中具有三个按钮(带图标)的自定义单元格

转载 作者:行者123 更新时间:2023-11-29 00:26:59 28 4
gpt4 key购买 nike

我将 PSButtonCell 用于链接,但三个单独的链接占用了太多空间,因此我尝试创建一个包含一行三个按钮的自定义单元格;基本上就像 3 个 float 图标。

我有一些用于创建带有图标的 tableview 的代码,但目前我不知道如何正确地分隔它们(所有图标目前重叠),而且我不知道我应该如何将点击监听器添加到意见。这看起来像我可以修改来做我想做的事吗?如果没有,有人可以为我提供更好的解决方案吗?非常感谢 这是我的图标代码

- (id)tableView:(id)tableView viewForHeaderInSection:(NSInteger)section {
if (section == 1) {
UIView *headerView = [[UIView alloc] initWithFrame:(CGRect){{0, 0}, {320, kHeaderHeight}}];
headerView.backgroundColor = UIColor.clearColor;
headerView.clipsToBounds = YES;

// icon
UIImage *bugicon = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/Bug.png", kSelfBundlePath]];
UIImageView *bugiconView = [[UIImageView alloc] initWithImage:bugicon];
bugiconView.frame = (CGRect){{0, 21}, bugiconView.frame.size};
// bugiconView.center = (CGPoint){headerView.center.x, bugiconView.center.y};
bugiconView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin;
[headerView addSubview:bugiconView];

UIImage *payicon = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/Paypal.png", kSelfBundlePath]];
UIImageView *payiconView = [[UIImageView alloc] initWithImage:payicon];
payiconView.frame = (CGRect){{0, 21}, payiconView.frame.size};
// payiconView.center = (CGPoint){headerView.center.x, payiconView.center.y};
payiconView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin;
[headerView addSubview:payiconView];

UIImage *btcicon = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/bitcoin.png", kSelfBundlePath]];
UIImageView *btciconView = [[UIImageView alloc] initWithImage:btcicon];
btciconView.frame = (CGRect){{0, 21}, btciconView.frame.size};
// btciconView.center = (CGPoint){headerView.center.x, btciconView.center.y};
btciconView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin;
[headerView addSubview:btciconView];

最佳答案

您添加的所有 subview 都位于同一位置。所有 UIView 框架都从相同的 'x' 位置 '0' 开始。您需要更改 2nd 和 3rd frame x positon 。第二个和第三个 UIView(更改您的 CGRect 'X' 位置)

bugiconView.frame = (CGRect){{0, 21}, bugiconView.frame.size};
payiconView.frame = (CGRect){{0, 21}, payiconView.frame.size};
btciconView.frame = (CGRect){{0, 21}, btciconView.frame.size};

希望对你有帮助

关于ios - objective-c 中具有三个按钮(带图标)的自定义单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42730753/

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