相关疑难解决方法(0)

解释iOS7中的automaticAdjustsScrollViewInsets,extendedLayoutIncludesOpaqueBars,edgesForExtendedLayout之间的区别

我一直在阅读很多关于iOS7 UI过渡的内容.

我不能够得到什么这三个属性automaticallyAdjustsScrollViewInsets,extendedLayoutIncludesOpaqueBars,edgesForExtendedLayout

例如,我试图让我的视图控制器从状态栏下面开始,但我无法实现它.

xcode objective-c uiviewcontroller ios ios7

247
推荐指数
4
解决办法
8万
查看次数

如何在UICollectionView上设置单元格的位置

我有一个包含UICollectionView的UIViewController.但是UICollectionView并没有填满所有的UIViewController.

我发现有一些空间的高度等于单元格和UICollectionView顶部边缘之间的NavigationBar的高度.我不知道如何在UICollectionView中将单元格位置设置为(0,0).(像这样,空间是红色矩形)

在此输入图像描述

我找到了这个链接如何设置UICollectionViewCell的位置?我将UICollectionViewFlowLayout子类化(以下是我的代码)

MZMCollectionViewFlowLayout.h

#import <UIKit/UIKit.h>

@interface MZMCollectionViewFlowLayout : UICollectionViewFlowLayout

@end
Run Code Online (Sandbox Code Playgroud)

MZMCollectionViewFlowLayout.m

#import "MZMCollectionViewFlowLayout.h"

@implementation MZMCollectionViewFlowLayout

- (CGSize)collectionViewContentSize
{
    return [super collectionViewContentSize];
}

- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
{
    return [super layoutAttributesForElementsInRect:rect];
}

- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"MZMCollectionViewFlowLayout layoutAttributesForItemAtIndexPath");
    if (indexPath.section == 0 && indexPath.row == 1) // or whatever specific item you're trying to override
    {
        UICollectionViewLayoutAttributes *layoutAttributes = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath];
        layoutAttributes.frame = CGRectMake(0,0,100,100); // or whatever...
        return layoutAttributes;
    }
    else
    {
        return [super layoutAttributesForItemAtIndexPath:indexPath];
    }
}

@end …
Run Code Online (Sandbox Code Playgroud)

ios uicollectionview uicollectionviewlayout

9
推荐指数
2
解决办法
1万
查看次数

UICollectionViewCell Y位置已锁定

我不知道这是怎么发生的,但我的UICollectionViewCell不知何故从顶部向下移动,我无法将其拉回来.此外,界面构建器中的Y位置锁定为64,请参见屏幕截图.

图片

任何帮助都是极好的.比你!

xcode objective-c

2
推荐指数
1
解决办法
831
查看次数