【发布时间】:2017-03-11 02:47:26
【问题描述】:
我使用 PSButtonCell 的链接,但三个单独的占用太多空间,所以我试图创建一个自定义单元格,其中三个按钮排成一行;基本上就像 3 个浮动图标。
我有一些用于创建带有图标的表格视图的代码,但目前我不知道如何正确分隔它们(当前所有图标都重叠),而且我不知道应该如何将点击侦听器添加到意见。这看起来像是我可以修改以做我想做的事情吗?如果没有,是否有人可以为我提供更好的解决方案?非常感谢这是我的图标代码
- (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];
【问题讨论】:
-
“这看起来像是我可以修改以做我想做的事情吗” 我们怎么知道你有什么能力?如果您“不知道如何正确分隔它们(当前所有图标都重叠),并且我不知道应该如何将点击侦听器添加到视图中”,那么我不得不说这段代码对您没有好处.
标签: ios objective-c uibutton uikit