20年目睹之怪bug

2022-01-15  本文已影响0人  携一两本单色书来
  1. UITextFied 里输入
    123 456 789
    然后选中456,删除
    会将123 和456中间的空格也删掉。。
    我只是要删掉456啊!!谁叫你给我删空格的!!

  2. ios 14.0 UIMenuController 不出现
    amazing ?
    其他项目里都可以,写得demo也可以。就是目前项目中未出来,原因未知~

  1. iOS 14.7.1
    reloadInputViews 会触发keyboardWillHide的通知,造成input跳动~
- (void)viewDidLoad {
    [super viewDidLoad];
    _tf = [[UITextView alloc] initWithFrame:CGRectMake(10, 100, 200, 50)];
    _tf.backgroundColor = [UIColor redColor];
    [self.view addSubview:_tf];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardHidden:) name:UIKeyboardWillHideNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardShow:) name:UIKeyboardWillShowNotification object:nil];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    UIView *vie = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 100)];
    vie.backgroundColor = [UIColor redColor];
    self.tf.inputAccessoryView = self.tf.inputAccessoryView != nil ? nil : vie;
    [self.tf reloadInputViews];
}

- (void)keyboardHidden:(NSNotification *)noti {
    NSLog(@"keyboardHidden");
}
- (void)keyboardShow:(NSNotification *)noti {
    NSLog(@"keyboardShow");
}

14.7.1 log:

inputAccessoryView 为nil时
keyboardShow

nputAccessoryView 为存在View时:
keyboardHidden
keyboardShow

13.6 log:

inputAccessoryView 为nil时
keyboardShow

nputAccessoryView 为存在View时:
keyboardShow

可以看到,当nputAccessoryView 存在时,14.7会多执行一次keyboardHidden通知

目前解决方案:
刷新键盘时,添加控制:

    self.reloadInputViewLock = YES;
    [self.inputBoxView.textContainerView.textView.internalTextView reloadInputViews];
    self.reloadInputViewLock = NO;

- (void)keyboardHidden:(NSNotification *)noti
{
    if (self.reloadInputViewLock) {
        return;
    }
。。。
}

当打包机的内存不够时候,会出现部分图片资源打不进去的问题。
打出来的包在部分机型上会出问题

** Assertion failure in -[_UIImageCGImageContent initWithCGImage:scale:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3901.4.2/_UIImageContent.m:336
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Need an imageRef'

在组件打包为二进制后,部分宏定义会失效,比如断言,或者当前开发环境等。 可能会遗漏一部分错误信息,但是优点也非常明显,加快了编译速度.

上一篇下一篇

猜你喜欢

热点阅读