iOS16.3.1某些界面内存溢出崩溃,导航栏按钮设置问题,UIBarButtonItem设置

更新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];

posted @ 2023-03-08 10:50  JustToGo  阅读(251)  评论(0编辑  收藏  举报