我的自定义单元格没有按照我的意愿加载。我现在已经改变了很长一段时间,我知道我不会做我应该做的事情。
除了设计单元格之外,我没有做任何事情,在我的单元格原型上设置我的约束,并为它分配我为它制作的自定义类,但我根本没有改变。我认为问题在于,我在自定义单元格类中缺少方法。
这是我的设计:
以下是它所呈现的内容:
我不知道发生了什么,但我的图像没有显示,文本框忽略了限制。如果我做了一些公然或缺少某些事情,请填写我的信息?
编辑:我实际上遇到了一个疯狂的长错误。我是否应该超载一些东西以防止其自动布局或什么?2014-07-18 18:23:43.897 MeNext[4703:60b] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this:
(1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x10933fab0 V:[UILabel:0x10933f900(90)]>",
"<NSLayoutConstraint:0x1093411c0 V:|-(0)-[UILabel:0x10933f900] (Names: '|':UITableViewCellContentView:0x10933f820 )>",
"<NSLayoutConstraint:0x109341260 V:[UILabel:0x10933f900]-(0)-| (Names: '|':UITableViewCellContentView:0x10933f820 )>",
"<NSAutoresizingMaskLayoutConstraint:0x10933a2f0 h=--& v=--& V:[UITableViewCellContentView:0x10933f820(91)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x10933fab0 V:[UILabel:0x10933f900(90)]>
Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2014-07-18 18:23:43.900 MeNext[4703:60b] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x109317d90 V:[UILabel:0x109317c50(90)]>",
"<NSLayoutConstraint:0x10933c290 V:|-(0)-[UILabel:0x109317c50] (Names: '|':UITableViewCellContentView:0x109332840 )>",
"<NSLayoutConstraint:0x10933c330 V:[UILabel:0x109317c50]-(0)-| (Names: '|':UITableViewCellContentView:0x109332840 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1095685f0 h=--& v=--& V:[UITableViewCellContentView:0x109332840(91)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x109317d90 V:[UILabel:0x109317c50(90)]>
Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2014-07-18 18:23:43.902 MeNext[4703:60b] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x109320d30 V:[UILabel:0x109332d50(90)]>",
"<NSLayoutConstraint:0x109337ad0 V:|-(0)-[UILabel:0x109332d50] (Names: '|':UITableViewCellContentView:0x109332c90 )>",
"<NSLayoutConstraint:0x109337b70 V:[UILabel:0x109332d50]-(0)-| (Names: '|':UITableViewCellContentView:0x109332c90 )>",
"<NSAutoresizingMaskLayoutConstraint:0x109348490 h=--& v=--& V:[UITableViewCellContentView:0x109332c90(91)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x109320d30 V:[UILabel:0x109332d50(90)]>
Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2014-07-18 18:23:43.904 MeNext[4703:60b] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x109340530 V:[UIButton:0x109340340(17)]>",
"<NSLayoutConstraint:0x109340c60 V:[UIButton:0x109340a20(17)]>",
"<NSLayoutConstraint:0x109341120 V:|-(20)-[UIButton:0x109340340] (Names: '|':UITableViewCellContentView:0x10933f820 )>",
"<NSLayoutConstraint:0x109341350 V:[UIButton:0x109340a20]-(20)-| (Names: '|':UITableViewCellContentView:0x10933f820 )>",
"<NSAutoresizingMaskLayoutConstraint:0x10933a2f0 h=--& v=--& V:[UITableViewCellContentView:0x10933f820(91)]>",
"<NSLayoutConstraint:0x1093413a0 V:[UIButton:0x109340340]-(16)-[UIButton:0x109340a20]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x109340c60 V:[UIButton:0x109340a20(17)]>
Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2014-07-18 18:23:43.905 MeNext[4703:60b] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x10933b500 V:[UIButton:0x10933b310(17)]>",
"<NSLayoutConstraint:0x10933bd30 V:[UIButton:0x10933baf0(17)]>",
"<NSLayoutConstraint:0x10933c1f0 V:|-(20)-[UIButton:0x10933b310] (Names: '|':UITableViewCellContentView:0x109332840 )>",
"<NSLayoutConstraint:0x10933c420 V:[UIButton:0x10933baf0]-(20)-| (Names: '|':UITableViewCellContentView:0x109332840 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1095685f0 h=--& v=--& V:[UITableViewCellContentView:0x109332840(91)]>",
"<NSLayoutConstraint:0x10933c470 V:[UIButton:0x10933b310]-(16)-[UIButton:0x10933baf0]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x10933bd30 V:[UIButton:0x10933baf0(17)]>
Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2014-07-18 18:23:43.906 MeNext[4703:60b] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x1093333d0 V:[UIButton:0x109333200(17)]>",
"<NSLayoutConstraint:0x109336890 V:[UIButton:0x109336670(17)]>",
"<NSLayoutConstraint:0x109337a30 V:|-(20)-[UIButton:0x109333200] (Names: '|':UITableViewCellContentView:0x109332c90 )>",
"<NSLayoutConstraint:0x109337c60 V:[UIButton:0x109336670]-(20)-| (Names: '|':UITableViewCellContentView:0x109332c90 )>",
"<NSAutoresizingMaskLayoutConstraint:0x109348490 h=--& v=--& V:[UITableViewCellContentView:0x109332c90(91)]>",
"<NSLayoutConstraint:0x109337d00 V:[UIButton:0x109333200]-(16)-[UIButton:0x109336670]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x109336890 V:[UIButton:0x109336670(17)]>
Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
编辑2:这是我的CellForRowAtIndexPath
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"QueueCell" forIndexPath:indexPath];
cell.textLabel.text = _tracks[indexPath.row][@"title"];
if(_thumbnails.count == _tracks.count)
{
[cell.imageView sd_setImageWithURL:[NSURL URLWithString:_thumbnails[indexPath.row]]];
}
return cell;
}
答案 0 :(得分:2)
如果您想将ImageView放在您想要的位置,并且您的文本遵循约束,我认为您需要将UITableViewCell子类化。创建UITableViewCell类型的新类,在Storyboard中将其挂钩,然后使用
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:@"QueueCell"];
这适用于Storyboard。
dequeueReusableCellWithIdentifier:@"" forIndexPath:indexPath
不适用于Storyboard。
然后,在您的单元格类中,连接您的IBOutlet ImageView,标签等