iOS开发之UIAlertController报错原因

1、报错信息:Actions added to UIAlertController of style UIAlertActionStyleCancel must have a title when running in UIUserInterfaceIdiomPad

这是由于取消标题(cancelTitle)为空导致的

if (cancelTitle.length > 0) {

  UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:cancelTitle style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {         

   }];

  [alertCtl addAction:actionCancel];

}

 

2、报错信息:UIAlertController can only have one action with a style of UIAlertActionStyleCancel

这是添加了多个UIAlertActionStyleCancel类型的选项,去掉多余的保留一个即可

posted @ 2020-09-07 10:48  kawerd  阅读(561)  评论(0编辑  收藏  举报