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.
Asked
Active
Viewed 71 times
0
-
Show some code. – Saqib Omer Apr 03 '18 at 10:18
-
3So you put a table view inside an alert view controller? This seems **horribly** wrong. I'd strongly suggest creating a custom UI instead. – Tamás Sengel Apr 03 '18 at 10:18
-
@the4kman Exactly I m thinking, i wanted to see the sceen. – dahiya_boy Apr 03 '18 at 10:19
-
Can you suggest an alternative? – Abhishek Master Apr 03 '18 at 10:19
-
@AbhishekMaster It depends what you wanted to achieve. Define your ques properly, it is highly unclear. – dahiya_boy Apr 03 '18 at 10:19
-
@AbhishekMaster I just did: create a custom UIView with an alert-like appearance. Build your own or use a Pod. Here's an example: https://stackoverflow.com/q/25379559/3151675 – Tamás Sengel Apr 03 '18 at 10:19
-
Just want to show tableview in alertview style , and get the row selection result – Abhishek Master Apr 03 '18 at 10:20
-
@AbhishekMaster Use child container in your main VC – dahiya_boy Apr 03 '18 at 10:21
2 Answers
4
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.

Duncan C
- 128,072
- 22
- 173
- 272
0
I would suggest you to create a custom UIViewController, add required functionality and present it as a Form Sheet. Refer https://developer.apple.com/library/content/featuredarticles/ViewControllerPGforiPhoneOS/PresentingaViewController.html

sarawanak
- 387
- 1
- 6
- 17