UIAlertController:每当我尝试启动UIAlertcontroller时,都没有定义UICollectionViewFlowLayout警告

Sha*_*e D 9 ios swift uialertcontroller swift2

我正在使用UIAlertController来获取用户输入和更新表格单元格.每当我尝试创建警报时,我都会在控制台中收到以下警告

2015-11-19 17:51:42.034 SimpleTableView [5488:584215]未定义UICollectionViewFlowLayout的行为,因为:

2015-11-19 17:51:42.035 SimpleTableView [5488:584215]项目高度必须小于UICollectionView的高度减去截面插入顶部和底部值,减去内容插入的顶部和底部值.

2015-11-19 17:51:42.036 SimpleTableView [5488:584215]相关的UICollectionViewFlowLayout实例是<_UIAlertControllerCollectionViewFlowLayout:0x7fd0a057c3d0>,它附加到; layer =; contentOffset:{0,0}; contentSize:{0,0}>集合视图布局:<_ UIAlertControllerCollectionViewFlowLayout:0x7fd0a057c3d0>.2015-11-19 17:51:42.036 SimpleTableView [5488:584215]在UICollectionViewFlowLayoutBreakForInvalidSizes上创建一个符号断点,以便在调试器中捕获它.

如众多博客所述,实施非常简单,

func displayAlertInfo(){
    let alertController = UIAlertController(title: "New Race", message: "Type in a new race", preferredStyle: .Alert)
    let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) { (_) in
        alertController.dismissViewControllerAnimated(true, completion: nil)
    }
    let addAction = UIAlertAction(title: "Add", style: .Default) { (_) in
        let textFieldInput = alertController.textFields![0] as UITextField
        let newRace = textFieldInput.text?.capitalizedString
        DataManager.sharedInstance.addRace(species: self.species, race: newRace!)
        let newIndexPath = NSIndexPath(forRow: self.races.count - 1, inSection: 0)
        self.racesTableVew.insertRowsAtIndexPaths([newIndexPath], withRowAnimation: UITableViewRowAnimation.Automatic)
    }

    alertController.addTextFieldWithConfigurationHandler { (textField) -> Void in
        textField.placeholder = "New Race"
    }

    alertController.addAction(cancelAction)
    alertController.addAction(addAction)

    self.presentViewController(alertController, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)

我在导航按钮上调用此功能.警报显示正确,但每次我尝试点击创建警报的按钮时,我都会继续收到此警告.我做错了什么或者我跳过了什么?

编辑:添加屏幕截图:通过tableView从导航项按钮调用警报.

在此输入图像描述

Mak*_*Mak 13

你需要打电话

alertcontroller.view.setNeedsLayout()
Run Code Online (Sandbox Code Playgroud)

就在之前

self.presentViewController(alertController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

资料来源:https://forums.developer.apple.com/thread/18294(最后答案)