博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS 知识点
阅读量:4647 次
发布时间:2019-06-09

本文共 2020 字,大约阅读时间需要 6 分钟。

1、用 命令 “ -fno-objc-arc” 将ARC工程中的一个.m文件单独设置为MRC编码编译

  步骤:ProjectName -> Target -> Build Phases ->  .m -> Complier flags -> 填写命令 "-fno-objc-arc "

2、禁止 TableView的header的悬浮,添加以下代码即可

//禁止 cell header 悬浮

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {

    CGFloat sectionHeaderHeight = 50;

    if(scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {

        scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);

    } else if (scrollView.contentOffset.y>=sectionHeaderHeight) {

        scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);

    }

}

 

3、 打印字体库

//    打印字体库

    for(NSString *familyName in [UIFont familyNames]){

        NSLog(@"Font FamilyName = %@",familyName); //*输出字体族科名字

        for(NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {

            NSLog(@"\t%@",fontName);         //*输出字体族科下字样名字

        }

    }

 

4、解决tableView cell 不贴边,在 cellForRowAtIndexPath 代理方法中添加

 

//tableViewcell 不贴边解决2

    if ([cell respondsToSelector:@selector(setSeparatorInset:)]){

        [cell setSeparatorInset:UIEdgeInsetsZero];

    }

 

5、 获取cell在tableView 中的位置 或者屏幕上的位置

  可以在didselectRowAtIndexPath方法里使用如下代码

 

  CGRect rectInTableView = [tableView rectForRowAtIndexPath:indexPath];

  CGRect rectInSuperview = [tableView convertRect:rectInTableView toView:[tableView superview]];

 6、获取cell在collectionView中的位置或屏幕上的位置

  -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath

{
       UICollectionViewCell * cell = (UICollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
    
    /*
     获取当前点击的cell位置大小,以此设定view2初始大小和位置
     */
    //cell在当前collection的位置
    CGRect cellRect = [_collectionView convertRect:cell.frame toView:_collectionView];
    NSLog(@"987654321- %f - %f # %f - %f",cellRect.origin.x,cellRect.origin.y,cellRect.size.width,cellRect.size.height);
    //cell在当前屏幕的位置
    CGRect rect2 = [_collectionView convertRect:cellRect toView:self.view];
    NSLog(@"987654321- %f - %f # %f - %f",rect2.origin.x,rect2.origin.y,rect2.size.width,rect2.size.height);
}

 

 

 

转载于:https://www.cnblogs.com/wjw-blog/p/8601049.html

你可能感兴趣的文章
Lambda--持续学习中
查看>>
简单谈谈面向对象和面向过程的区别
查看>>
Intellij IDEA 配置Tomcat远程调试
查看>>
python3 进程和线程(一)
查看>>
python-综合练习题(if条件语句,while循环,奇数偶数
查看>>
C语言基础-第三章
查看>>
PowerDesigner教程系列(一)概念数据模型
查看>>
python常用类库总结
查看>>
题解 CF962C 【Make a Square】
查看>>
只读数据文件损坏恢复
查看>>
k8s集群上线web静态网站
查看>>
【转】Impala和Hive的关系
查看>>
IDEA操作git
查看>>
有向图算法之拓扑排序
查看>>
windows 下安装elasticsearch
查看>>
C语言学习12:带参数的main函数,无指定的函数形参,调用库函数处理无指定的函数形参,...
查看>>
禁止某程序联网
查看>>
[LOJ6191][CodeM]配对游戏(概率期望DP)
查看>>
mysql中utf8和utf8mb4区别
查看>>
谈谈源码管理那点事儿(一)——源码管理十诫(转)
查看>>