小编pet*_*ard的帖子

在AFNetworking中使用URL参数和JSON主体进行POST

我想进行一个包含URL参数和JSON主体的POST调用:

URL http://example.com/register?apikey=mykey
JSON { "field" : "value"}
Run Code Online (Sandbox Code Playgroud)

如何在AFNNetworking中同时使用两个不同的序列化程序?这是我的代码,缺少URL参数:

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
[manager POST:@"http://example.com/register" parameters:json success:^(AFHTTPRequestOperation *operation, id   responseObject) {
Run Code Online (Sandbox Code Playgroud)

post afnetworking-2

6
推荐指数
1
解决办法
1317
查看次数

sectionInset不使用AutoLayout在iOS8中使用UICollectionView estimatedItemSize

sectionInset.left当使用自调整单元格时,我不能让我的UICollection正确设置边距estimatedItemSize.UICollectionview的单元格应具有稍微固定的单元格高度,但根据文本长度应具有动态宽度.

以下是启用自我调整大小时的外观:

在此输入图像描述

当自动调整大小时:

在此输入图像描述

奇怪的是,它似乎sectionInset.right正在起作用,即在UICollectionView的右侧添加了边距.

这是我的自定义UICollectionViewFlowLayout,我正在使用注释切换自我大小模式.

class myFlow: UICollectionViewFlowLayout {
    required init(coder: NSCoder) {
    super.init(coder: coder)

        self.minimumLineSpacing = 1
//        self.estimatedItemSize = CGSize(width: 100, height: 35)
        self.sectionInset.left = 20
    }
Run Code Online (Sandbox Code Playgroud)

和我的自定义UICollectionView:

class myCV: UICollectionView {
    required init(coder decoder: NSCoder) {
        super.init(coder: decoder)

        self.layer.cornerRadius = 5.0
        self.layer.borderWidth = 1.0
        self.layer.borderColor = UIColor.lightGrayColor().CGColor

    }
}
Run Code Online (Sandbox Code Playgroud)

我使用AutoLayout在UICollectionView单元格中布置了标签:

在此输入图像描述

autolayout uicollectionview uicollectionviewlayout swift ios8

5
推荐指数
1
解决办法
1101
查看次数