您的位置:首页 > 其它

小技巧

2016-02-01 18:01 190 查看

1. 转移APPDelegate
-application: didFinishLaunchingWithOptions:
方法中的代码

情景一:第三方初始化,且不需要上面方法中的option参数时,可以新建一个辅助类,将相关代码放到
+ load
方法中

情景二:在程序启动后执行(didFinishLaunching完成后)

+ (void)load
{
// block 对observer的捕获,早于函数的返回,所以如果不加__block修饰在block调用时会得到nil
__block id observer = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidFinishLaunchingNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
[self shareInstance];
NSLog(@"%@",observer);
[[NSNotificationCenter defaultCenter]removeObserver:observer];
}];
}


2. 消除Group TableView 首个selection与顶部的间距

1.代码:

tableView.tableHeaderView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];


2.storyBoard:

2.1 第0个section上拖入一个View



2.2 在Runtime Attribute中设置frame属性



3.高度值应该是多少:

3.1 当高度是0时,header高度会被置为默认值

3.2 当高度大于0且小于 1 / ScreenScale / 2.0 时,header不会在另一个像素中渲染

3. XCode 小技巧

方法调用查看:

选中要查看的方法,control + 1,弹出菜单中选择callers(不要看错选成下方的Callees),可以查看有哪些方法调用了当前方法。









内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: