目标c中带有三个button(带图标)的自定义单元格

我正在使用PSButtonCell的链接,但三个单独占用太多的空间,所以我试图创build一个自定义单元格与三个button在一行; 基本上像3个浮动图标。

我有一些代码用于创build一个带有图标的桌面视图,但是目前我不知道如何正确地分配它们(所有的图标都是重叠的),我不知道应该如何将视图添加到视图中。 这看起来像我可以修改做我想要的东西吗? 如果没有人有更好的解决scheme,他们可以为我提供? 非常感谢我的代码为图标

- (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]; 

你将所有的子视图添加到相同的位置。 所有的UIView框架从相同的'x'位置'0' 。 您需要更改第2帧和第3帧x位置。 ( Change your CGRect 'X' position)第二和第三个UIView

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

希望能帮助到你…