相关疑难解决方法(0)

什么是NSLayoutConstraint"UIView-Encapsulated-Layout-Height",我应该如何强制它干净地重新计算?

UITableView在iOS 8下运行,并且我在故事板中使用来自约束的自动单元格高度.

我的一个单元格包含一个UITextView,我需要它根据用户输入收缩和扩展 - 点击缩小/扩展文本.

我这样做是通过向文本视图添加运行时约束并更改约束上的常量以响应用户事件:

-(void)collapse:(BOOL)collapse; {

    _collapsed = collapse;

    if(collapse)
            [_collapsedtextHeightConstraint setConstant: kCollapsedHeight]; // 70.0
        else
            [_collapsedtextHeightConstraint setConstant: [self idealCellHeightToShowFullText]];

    [self setNeedsUpdateConstraints];

}
Run Code Online (Sandbox Code Playgroud)

当我这样做时,我将其包装在tableView更新中并致电[tableView setNeedsUpdateConstraints]:

[tableView beginUpdates];

[_briefCell collapse:!_showFullBriefText];

[tableView setNeedsUpdateConstraints];
// I have also tried 
// [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationTop];
// with exactly the same results.

[tableView endUpdates];
Run Code Online (Sandbox Code Playgroud)

当我这样做时,我的单元格确实扩展(并在进行动画时动画)但是我得到一个约束警告:

2014-07-31 13:29:51.792 OneFlatEarth[5505:730175] Unable to simultaneously satisfy constraints.

Probably at least one of the constraints in the following list is one …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch uitableview ios autolayout ios-autolayout

243
推荐指数
9
解决办法
8万
查看次数

今天iPad的扩展高度远大于指定

My Today扩展需要基于窗口小部件显示的内容具有动态高度.我能够通过在最底部元素上添加约束来实现这一点:底部布局指南的顶部小于或等于最底部元素的底部,常量为0,优先级为999,乘数为1.

这与iPhone上的预期完全一样 - 小部件高度适合所有内容,并且在显示下一个小部件之前应用默认的底部边距.

但是在iPad上似乎将我的小部件的高度设置为等于最大高度通知中心将允许小部件 - 我的小部件下方有很多空间,它几乎全屏.

如何删除多余的空间?

我确切地知道问题是什么,但我不确定如何解决它 - 请参阅"问题"部分.首先让我解释一下设置:

设置:
我在故事板中设置了此扩展的视图,没有任何编程方式.视图由垂直堆叠的5个元素组成,其他一些元素水平堆叠.这些是从上到下的垂直线的自动布局约束 - 其中未声明的优先级为1000,乘数1:

UILabel: height = 35, top space to top layout guide with constant of 10
UIButton: equal height and width to a different button (whose aspect ratio is 1:1, there is no fixed width/height), top space to label 10
UIButton: equal height and width to same button, top space to above button 8
UIButton: equal height and width to same button, top space to above …
Run Code Online (Sandbox Code Playgroud)

ios autolayout ios8 ios-app-extension ios8-today-widget

51
推荐指数
1
解决办法
1511
查看次数

如何设置今日窗口小部件扩展的高度?

如何在通知中心更改应用程序今日扩展程序的高度?

我尝试使用Interface Builder和Code,Interface Builder显示高度为600的视图,但它没有在设备上应用此高度.

看起来我不能让它大于80像素......

在此输入图像描述

ios xcode6 ios8 ios-app-extension

38
推荐指数
5
解决办法
3万
查看次数

使用自动布局为iOS8今日扩展设置固定高度

我正在尝试实现一个简单的今天小部件,其中包含一个固定高度的单个标签.

在文档中它说:

如果窗口小部件具有要显示的其他内容,则可以依赖"自动布局"约束来适当调整窗口小部件的高度.

但是我一直得到"无法同时满足约束"的警告.

这是我尝试过的:

  1. 创建一个新的"今日扩展"目标,它创建一个带有"Hello World"标签和视图控制器的故事板.
  2. 将高度约束设置为"Hello World"标签.

在此输入图像描述

当我跑步时,我得到:

2014-09-18 21:13:07.123 TestWidget[23381:871330] 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 …
Run Code Online (Sandbox Code Playgroud)

ios autolayout ios8 today-extension

7
推荐指数
1
解决办法
1654
查看次数