问题标签 [pure-layout]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
609 浏览

ios - 子类 UIView 不可见,但内容可见

我将 UIView 子类化:http: //pastebin.com/MVk1XmPS,当我将它添加到 UIViewController 的另一个视图时:

红色背景不见了。似乎myView没有宽度和高度。但是内容是可见的:

照片 07 11 14 23 12 36

我必须对维度进行硬编码:

但它不应该根据内容的大小自动增长吗?我使用 swift、xcode6.1 和 iOS8.1

0 投票
1 回答
727 浏览

ios - UITableViewCell 中 contentView 的宽度对于每个单元格都不同

UITableViewController启用自动布局的故事板中定义的一个UITableViewCell子类以编程方式创建(没有 IB 原型单元)并通过updateConstraints使用PureLayout设置约束。

出于某种原因,表格视图的每个 contentView 都有不同的宽度,而不是使用UITableView.

在此处输入图像描述

这是子类的initandupdateConstraints方法UITableViewCell-

为什么 contentView (棕色)与表格视图的宽度不同?

0 投票
3 回答
7194 浏览

ios - iOS 如何通过 PureLayout 使两个视图居中

我想将我的 UIImageView 和 UILabel 居中,如下图所示。我使用了一个容器来包含UIImageView和UILabel,但是容器不适合UIImageView和UILabel的宽度,所以我需要设置容器的宽度。有什么方法可以解决问题而不设置宽度或计算视图的宽度?这是图片:

我的标签

0 投票
0 回答
175 浏览

ios - 添加附件类型后,iOS 8 UITableViewCell 约束中断

从技术上讲,约束不会中断,但它们会停止按预期工作。我已经分叉了 PureLayout 的 iOS 8 AutoLayout 示例来复制这个问题。简而言之,我有一个带有自定义单元格的 UITableView,如下所示:

在此处输入图像描述

添加后

它看起来像这样:

在此处输入图像描述

注意单元格标题和正文之间的间隙。

https://github.com/marcus30/TableViewCellWithAutoLayoutiOS8

0 投票
1 回答
178 浏览

ios - 图像视图在滚动视图中不可滚动并且不适合使用纯布局

我只是想将图像放入使用purelayout的主视图中的滚动视图中。

而我现在正在采取的是;

示例图像

请注意,红色背景的视图是滚动视图。而且图像不可滚动。

0 投票
1 回答
905 浏览

ios - 在 UIScrollView 中使用 PureLayout 库 pinEdge 右 UIView 不起作用或如何操作?

我正在使用PureLayout库。Github

UIScrollView作为全屏容器。

作为一个简单的例子,我有一个UIView(0,0,100,50)。我想将此视图的右边缘固定到UIScrollView.

我是这样做的:

我得到结果

在此处输入图像描述

我知道,我可以创建一个宽度与相同的UIView 容器,然后添加它并将所有自定义视图放入此容器中,但我想知道为什么我们不能直接使用.UIScrollViewsubviewscrollViewUIScrollView

0 投票
3 回答
2410 浏览

ios - 带有 Cocoapods 的 Swift 中的 PureLayout

使用cocoapods-0.37.2这是我的Podfile

我正在尝试PureLayout像这样导入我的 .swift 文件:

但我得到错误:

没有这样的模块“PureLayout”

为什么???我认为 Cocoapods-Bridging-Header.h在使用时会自行创建use_frameworks!

0 投票
1 回答
87 浏览

ios - CollectionViewCell 中的自动布局约束更改

我正在使用 PureLayout 创建约束

cellForItemAtIndexPath

然后在scrollDidView

尽管在调试时,我可以看到约束的常量发生了变化,但视图不会更新到新位置。

我也试过

如何更新视图的 ( _itemDetails,它指向 a 中的视图CollectionViewCell) 位置?

0 投票
1 回答
606 浏览

swift - Swift autolayout: update view's dimension

I'm using PureLayout

I'm doing all the layout by code, by the way.

I have a UIScrollView that functions like Facebook's news feed. My scroll view has some subviews. Let's call 'em "cards".

I've set my constraints inside updateConstraints as such:

And in layoutSubviews, this is where I resize the cards. Their respective height is being updated after an image is loaded from the internet (via NSURLConnection.sendAsynchronousRequest, fyi, but not related to this topic.) After that, I update my scrollView's height.

The problem is that they're not being aligned properly. It's like calling setNeedsLayout() (which eventually calls layoutSubviews() -- correct me if I've mistaken) that does not align the content at all. I've also made sure that setNeedsUpdateConstraints() is called as well.

I've tried calling this in layoutSubviews...

...but I get some kind of warning:

(ContentBox is my UIView for the card)

The cards look messed up. What should I do to align my cards properly?

I'd gladly answer side comments regarding the code if it helps understand the question. :) Suggestions on the side aren't bad either.

0 投票
0 回答
148 浏览

ios - Purelayout - 动态两个标签的中心图标

我在以下示例中添加了一个箭头图标:https ://github.com/smileyborg/TableViewCellWithAutoLayout

这将以多行正文标签为中心。但我希望我的图标居中单行标签和多行bodyLabel。