Jos*_*ork 8 objective-c uitableview ios autolayout
我可能会犯这个错误.所以我创建了一个UITableView,它基本上有一个自动布局尾随空间设置为主视图.我正在为这个表创建一个自定义单元格,所以我在原型单元格上进行定制,定制它,并为它创建我的类.这一切都很好.
我似乎无法解决的是自定义单元格不是实际表格单元格的整个宽度,因此只显示白色背景.如果我不使用自定义单元格,则可以使用整个宽度表单元格.
我为单元格内容设置了约束,以便背景图像填充单元格.
我究竟做错了什么?让我知道您需要帮助解决这个问题.
ProfileCustomCell.h
#import <UIKit/UIKit.h>
@interface ProfileCustomCell : UITableViewCell {
}
@property (nonatomic, strong) IBOutlet UILabel *nameLabel;
@property (nonatomic, strong) IBOutlet UIImageView *profileImageView;
@end
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
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];
Run Code Online (Sandbox Code Playgroud)

您可以发布代码吗?
您是否启用了 “使用自动布局”和“使用大小类”,如下所示,首先在表视图和表视图单元格中执行此操作。然后告诉我您的问题

1)之后选择图像和标签,然后执行以下操作

2)选择图像并执行以下操作

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

您可以检查以下链接吗:
| 归档时间: |
|
| 查看次数: |
10872 次 |
| 最近记录: |