"cellForRowAtIndexPath" 未调用 alertviewcontroller 内的表视图

"cellForRowAtIndexPath" for a tableview inside alertviewcontroller not called

我正在 alertviewcontroller 中添加一个 table 视图,我已将委托和数据源提供给 table。调用除 cellForRowAtIndexPath 之外的所有委托和数据源方法。我有 return 节中行数的静态值以防止 0 行。它仍在发生。

您不应该修改 UIAlertController 的视图层次结构。你要么需要创建自己的视图控制器来模仿警报控制器,要么找到一个框架来为你做这件事。

引用 Apple 文档:

The view hierarchy for this class is private and must not be modified.

我建议您创建一个自定义 UIViewController,添加所需的功能并将其呈现为表单 Sheet。参考 https://developer.apple.com/library/content/featuredarticles/ViewControllerPGforiPhoneOS/PresentingaViewController.html