在 tableViewCell 中更改约束
change constraint inside tableViewCell
我需要更改 UITableViewCell
中 UIView
的宽度约束。通常我会为约束创建一个 IBOutlet
但我该如何处理它,因为它是一个动态原型 tableView ?请推荐
谢谢!
您可以通过以下方式完成
通过动态创建新视图
UIView *v=[[UIView alloc]init];
v.frame=CGRectMake(0, 0, 500, 250);
或通过标签访问视图或通过访问 -(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
中的内容视图子视图
UIView *v=[cell.contentView.subviews objectAtIndex:0];
v.frame=CGRectMake(0, 0, 500, 250);
希望对您有所帮助
我需要更改 UITableViewCell
中 UIView
的宽度约束。通常我会为约束创建一个 IBOutlet
但我该如何处理它,因为它是一个动态原型 tableView ?请推荐
谢谢!
您可以通过以下方式完成
通过动态创建新视图
UIView *v=[[UIView alloc]init]; v.frame=CGRectMake(0, 0, 500, 250);
或通过标签访问视图或通过访问
中的内容视图子视图-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
UIView *v=[cell.contentView.subviews objectAtIndex:0]; v.frame=CGRectMake(0, 0, 500, 250);
希望对您有所帮助