基础知识点笔记

2021-03-13  本文已影响0人  CrazySteven

关于SceneDelegate的介绍网上已经有很多了,这里做个笔记来记录一下。

不使用SceneDelegate
使用SceneDelegate

写代码的时候在模拟器上显示正常,到我真机上就出了问题,发现是app跟随系统深色主题,view,label等控件都变成了深色系


全局禁用深色模式(暗黑模式)

Info.plist中增加Appearance,值为Light

修改textfield的时候报错'Access to UITextField's _placeholderLabel ivar is prohibited. This is an application bug

以前的写法
[_nameTF setValue:[UIColor lightGrayColor] forKeyPath:@"_placeholderLabel.textColor"];
现在改成

#import <objc/message.h>
if (@available(iOS 13,*)){
  Ivar ivar =  class_getInstanceVariable([UITextField class], "_placeholderLabel");
  UILabel *placeholderLabel = object_getIvar(self.nameTF, ivar);
  placeholderLabel.textColor = [UIColor lightGrayColor];
}else {
  [_nameTF setValue:[UIColor lightGrayColor] forKeyPath:@"_placeholderLabel.textColor"];
}

M1芯片的电脑,若Xcode使用Rosetta打开,创建Viewxib文件可能会报错An internal error occured. Editing functionality may be limited
解决办法就是去掉Rosetta


清除模拟器缓存


后台返回数据<object returned empty description>
解决方法:
用string来接收,判断[string length] > 0即可


<NSLayoutConstraint:0x6000034b7980 UIView:0x7ff21de0ce00.width == - 16 (active)>
这个错误约束是用系统的UIAlertController出现的,从iOS12.1开始,到iOS14.4还没修复。。。无解

版权声明:本文为 Crazy Steven 原创出品,欢迎转载,转载时请注明出处!

上一篇 下一篇

猜你喜欢

热点阅读