美文网首页
ios小知识总结

ios小知识总结

作者: 豆汁儿还是豆花儿 | 来源:发表于2020-06-29 10:56 被阅读0次

    1.设置隐藏push的子控制器的底部tabBar

     // 隐藏tabbar(push前调用)
     viewController.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:viewController animated:true];
    

    2.发布时去除NSLog

    在pch文件中写入以下函数

    #ifdef DEBUG
    #define NSLog(...) NSLog(__VA_ARGS__)
    #else
    #define NSLog(...)
    #endif
    

    3.UITextView自适应高度

    只需要两行代码即可。这样我们在UITextView中设置的文字就可以左右两边对齐显示,且自适应高度,可自由滑动。

     textView.textContainerInset = UIEdgeInsetsZero;
     textView.textContainer.lineFragmentPadding = 0;
    

    4.解决UITextView中UITextContainer布局被遮挡问题

    [textView scrollRangeToVisible:NSMakeRange(0, 0)];
    

    5.ios building for ios simulator, but the linked framework ''xxxx" was built for ios 解决

    有的framework ,不能再模拟器下运行,目前解决方式为:修改xcode编译模式。
    **在xcode中选择File->WorkSpace Settings->Build System 选择 Legacy Build System 就可以编译通过啦。
    6.防止动态库注入的方法导致dyld: dyld_sim cannot be loaded in a restricted process错误
    防止动态库注入的方法(iOS10以下有效)
    在Build Setting下搜索Other Linker Flags,添加一行

    -Wl,-sectcreate,__RESTRICT,__restrict,/dev/null
    

    这行代码加入以后,模拟器运行的话会报错误,真机没问题

    dyld: dyld_sim cannot be loaded in a restricted process

    报错

    1.项目报Multiple commands produce XXX 在File中选择Project Settings ->>>Build system 中更改为Legacy Build System 既可

    2. react native项目在打包时出现下列问题:

    xx/Build/Intermediates.noindex/ArchiveIntermediates/xx/BuildProductsPath/Release-iphoneos/xx.a(xx.o)
    ld: 500 duplicate symbols for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    网上有很多种解决方案,我这里不一一列出了。我用网上的方法试了一个遍,但是都解决不了。之后我自己琢磨出了一个笨的解决方案,希望对大家有帮助。
    我的解决方法:
    一般是pod内React.a应用重复
    复制xx/Build/Intermediates.noindex/ArchiveIntermediates/xx/BuildProductsPath/Release-iphoneos/xx.a(xx.o)括号中xx.o的类名xx,到pod下的React库内build phaess 下直接Filter查找,然后删掉找到的.h和.m文件。
    然后一个一个的找到并删除。

    相关文章

      网友评论

          本文标题:ios小知识总结

          本文链接:https://www.haomeiwen.com/subject/nwcofktx.html