Search code examples
iosswiftuitableviewuialertview

"cellForRowAtIndexPath" for a tableview inside alertviewcontroller not called


I am adding a tableview inside an alertviewcontroller , I have given delegate and datasource to the table. All delegate and datasource methods except cellForRowAtIndexPath are called. I have return a static value for number of rows in section to prevent 0 rows. Still it is occurring.


Solution

  • You are not supposed to modify the view hierarchy of a UIAlertController. You’ll either need to create your own view controller that mimics an alert controller or find a framework that does that for you.

    To quote the Apple docs:

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