更新iOS16新系统后,发现原有正常运行的页面,进入时卡死,联调发现内存激增,很快溢出崩溃。通过一行行代码注释调试,定位到是由于UIBarButtonItem不兼容问题导致。
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"删除" style:UIBarButtonItemStylePlain target:self action:@selector(clickDeleteButtonAction)];
这个方法新系统不兼容,导致内存激增溢出。替换成下面方法解决
UIButton*clickedBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 30, 30)]; [clickedBtn setTitle:@"删除" forState:UIControlStateNormal]; UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithCustomView:clickedBtn];