• iOS 知识点


    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(@" %@",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);
    }

     

     

     

  • 相关阅读:
    (萌O(∩_∩)O)哈希知识点小结
    hash应用以及vector的使用简介:POJ 3349 Snowflake Snow Snowflakes
    BestCoder Round #3HDU 4907
    搜索:POJ2251&POJ1426&POJ3087&POJ2488
    母函数初学四大题
    欧拉函数知识点总结及代码模板及欧拉函数表
    欧几里德与扩展欧几里德算法以及青蛙的约会~
    KMP 知识点总结
    HDU 1142 A Walk Through the Forest(dijkstra+记忆化DFS)
    HDU 1535 Invitation Cards(SPFA,及其优化)
  • 原文地址:https://www.cnblogs.com/wjw-blog/p/8601049.html
Copyright © 2020-2023  润新知