Tag: ios autolayout

什么是XCode 8中的“性格变化”?

我正在使用AutoLayout和Size类,但随着iOS10和新的Xcode 8.0的发布,有一个新的选项Vary for Traits 。 这是不同的宽度和高度的设备的大小Classe的替代品。 通过selectwidthcheckbox,它显示varying 14 compact width devices 。 通过selectheightcheckbox,它显示varying 18 compact height devices 。 通过select这两个checkbox,它显示varying 11 compact width regular height devices 。 如何使用这个选项? 我们可以像Xcode7.0一样使用大小类的AutoLayout吗? 如果有任何深入的知识,请解释。

一些滚动后,UITableViewdynamic单元格高度才会正确

我有一个UITableView自定义UITableViewCell使用自动布局在故事板中定义。 单元格有几个多行UILabels 。 UITableView似乎正确地计算单元格高度,但对于前几个单元格高度没有正确划分标签之间。 滚动一下后,一切都按预期工作(即使是最初不正确的单元格)。 – (void)viewDidLoad { [super viewDidLoad] // … self.tableView.rowHeight = UITableViewAutomaticDimension; } – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { TableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"TestCell"]; // … // Set label.text for variable length string. return cell; } 有什么我可能会失踪,这是导致汽车布局不能够在前几次工作? 我已经创build了一个演示这种行为的示例项目 。

什么是NSLayoutConstraint“UIView-Encapsulated-Layout-Height”,我该如何强迫它重新计算干净

我有一个UITableView在iOS 8下运行,我使用故事板中约束的自动单元格高度。 我的一个单元格包含单个UITextView ,我需要它根据用户input进行收缩和展开 – 点击缩小/展开文本。 我这样做是通过向文本视图添加一个运行时约束,并在约束条件中改变常量来响应用户事件: -(void)collapse:(BOOL)collapse; { _collapsed = collapse; if(collapse) [_collapsedtextHeightConstraint setConstant: kCollapsedHeight]; // 70.0 else [_collapsedtextHeightConstraint setConstant: [self idealCellHeightToShowFullText]]; [self setNeedsUpdateConstraints]; } 当我这样做,我把它包装在tableView更新,并设置tableView的需要updateConstraint: [tableView beginUpdates]; [_briefCell collapse:!_showFullBriefText]; [tableView setNeedsUpdateConstraints]; // I have also tried // [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationTop]; // with exactly the same results. [tableView endUpdates]; 当我这样做的时候,我的细胞确实膨胀了(并且在做animation时),但是我得到了一个约束警告: 2014-07-31 13:29:51.792 OneFlatEarth[5505:730175] Unable […]