iOS版 - 自定义表格单元格的UITableView不宽 [英] iOS - Custom table cell not full width of UITableView

查看:160
本文介绍了iOS版 - 自定义表格单元格的UITableView不宽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可能要对此错误的。所以我创建基本上有一个自动布局尾随空间设置到主视图的UITableView。我创建该表等等的原型细胞的药物我,定制它,并创建了类一个自定义单元格。这是所有工作得很好。

I may be going about this wrong. So I have created a UITableView that essentially has a auto-layout trailing space set to the main view. I am creating a custom cell for this table so I drug on a prototype cell, customized it, and created my class for it. That is all working just fine.

我似乎无法来解决是自定义单元格不打算实际的表格单元格这样的全宽白色背景上只是显示出来。如果我不使用自定义单元格的整个宽度表格单元格被利用。

What I can't seem to solve is the custom cell isn't going the full width of the actual table cell so a white background just shows up. If I don't use the custom cell the entire width table cell gets utilized.

我设置了​​约束条件的单元格内容,以便背景图片应该填充单元格。

I set the constraints for the cell content so that the background image should fill the cell.

我是什么做错了吗?让我知道你需要什么来帮助解决这个问题。

What am I doing wrong? Let me know what you need to help solve this.

ProfileCustomCell.h

#import <UIKit/UIKit.h>

@interface ProfileCustomCell : UITableViewCell {

}

@property (nonatomic, strong) IBOutlet UILabel *nameLabel;
@property (nonatomic, strong) IBOutlet UIImageView *profileImageView;

@end

ProfileCustomCell.m

#import "ProfileCustomCell.h"

@implementation ProfileCustomCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];

    if (self) {
        self.nameLabel.text = nil;
    }

    return self;

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end

的UITableView

[tableView registerNib:[UINib nibWithNibName:@"ProfileCustomCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"Cell"];

[tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];

ProfileCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

cell.nameLabel.text = [NSString stringWithFormat:@"%@", [child objectForKey:@"first_name"]];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];

推荐答案

可以张贴code请。

Can you post the code please .

您是否启用使用自动布局使用大小类如下做到这一点首先在这两个表视图和表格视图单元格。而且告诉我你的问题。

Did you enable the Use Auto layout and Use Size Classes as below do that first in both table view and table view cell .and tell me your problem

1),之后选择这两个图像和标签,并做如下

1)After that select both image and label and do as below

2)选择图像,然后做下面

2) Select the image and do below

3)选择标签的执行以下操作

3) select the label an do the following

您可以查看下面的链接:

Can you check the link below:

<一个href=\"http://stackoverflow.com/questions/29206375/table-cell-contenttitle-moving-left-after-selecting-cell/29210049#29210049\">Table单元格内容(标题)选择细胞后向左移动

这篇关于iOS版 - 自定义表格单元格的UITableView不宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆