学习日记

20161224

pod update失败  在空的master 文件夹中执行git pull 居然能够下载  之前执行pod update半天没反应,

pod repo push OkdeerSpecs Trainticket.podspec --allow-warnings --use-libraries --verbose  //push时报引入的头文件找不到需要加参数—use-libraries

pod lib create podTestLibrary:创建pod自带的框架

pod spec create podspecTest:创建spec文件(在已经有框架时)

20161226

合并两个frameWork:lipo -create ./Release-iphonesimulator/OkdeerPublic.framework/OkdeerPublic ./Release-iphoneos/OkdeerPublic.framework/OkdeerPublic  -output OkdeerPublic

lips -info 需要cd到xxx.framework中

制作静态库要设置Mach-o 为静态!!!!!

iOS7后台更新(Background fetch):https://onevcat.com/2013/08/ios7-background-multitask/  喵神的详细讲解

先调用ruper方法还是后调用,看super方法中是否用到修改的数据,如下面代码,super方法需要self.sectionInset则先设置self.sectionInset。但viewDidLoad等方法需要super方法完成才能在此基础上执行自身的自定义事件。故一般是先调用super方法,再调用自定义,在想要修改super方法中的入参时,才写那部分代码在super方法之前。

- (void)prepareLayout{

// We update the section inset before we layout

self.sectionInset = UIEdgeInsetsMake(CGRectGetHeight(self.collectionView.bounds) - _itemSize.height, 0, 0, 0); //在collectionView底部滚动

[super prepareLayout];

}

20161230

1,调用drawRect方法系统会自动调用layoutSubViews;在改变约束时,系统会自动掉用layoutSubViews方法。现在有个绘制梯形的自定义view类TrapezoidView,在drawRect方法中通过设置的path和CGColor绘制形状。改变约束时,系统会自动掉用layoutSubViews,但不会掉用drawRect重绘,这样新增加的部分就没有被绘制。如果外部掉用setNeedsDisplay显得有些多余,想在内部通过layoutSubViews掉用setNeedsDisplay,但这样会行程循环调用。这样增加了一个全局变量在防止循环调用:

- (void)drawRect:(CGRect)rect {

// Drawing code

UIBezierPath *path = [UIBezierPath bezierPath];

CGFloat scale = 1 / 10.0;

[path moveToPoint:CGPointMake(scale * rect.size.width, rect.origin.y)];

[path addLineToPoint:CGPointMake(CGRectGetMaxX(rect), rect.origin.y)];

[path addLineToPoint:CGPointMake(CGRectGetMaxX(rect), CGRectGetMaxY(rect))];

[path addLineToPoint:CGPointMake((rect.origin.x), CGRectGetMaxY(rect))];

self.shapPath = path;  //父类中绘制

[super drawRect:rect];

if (drawRectDispaly) {

drawRectDispaly = NO;

}

CCLog(@"=====drawRect");

}

static BOOL drawRectDispaly = NO;

// 因为约束改变,会调用layouSubViews,但不会掉用drawRect。用setNeedsDisplay会调用drawRect,drawRect会自动调用layoutSubviews

// 现在这样如果不做判断就会循环调用,增加一个全局变量,判断一下

- (void)layoutSubviews {

[super layoutSubviews];

if (drawRectDispaly) {

[self setNeedsDisplay];

}

drawRectDispaly = YES;

}

2,在layoutSubviews中调用的获取frame是最后的frame高度,不是约束前的高度,即要获取约束后的高度,可以在layoutSubviews中直接获取frame高度.

3,UITableIVew的UITableViewStyleGrouped style默认添加了headerView和footerView  添加个高度应该为self.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, 0.01)];去掉headerView,否则顶部会有间隙。另外每组之间的间隙是由section的HeaderView和footerView组成的设置高度为一个很小值就能去掉间隙.另外,控制器设置self.automaticallyAdjustsScrollViewInsets = NO;可以使tableView垂直填满控制器(这个情况还没遇到)。设置可以跟随滚动的sectionView可以用UITableViewStyleGrouped实现。



你可能感兴趣的:(学习日记)