Rohit_RK
Rohit_RK

Reputation: 405

How to add UIView on UIAlertController

How we can add the UIView on UIAlertController as we can do on the UIAlertView by using @"AccessoryView" but now it is deprecated in iOS 8 . So I want to use it with UIAlertController but how?

Upvotes: 2

Views: 6570

Answers (3)

Sachin
Sachin

Reputation: 31

You can add a UITableView on UITableViewCell , also CollectionView on the UITableviewCell. you have to specify datasources inside the cell classes according to the cell index.

register the child cell nib inside the - (void)awakeFromNib function

[self.collectionView registerNib:[UINib nibWithNibName:@“childCollectnCell” bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@“childCollectnCell”]

and Specify the datasources and delegates inside class

Upvotes: 0

Munahil
Munahil

Reputation: 2419

You can subclass UIViewController and make CustomAlertViewController and use presentViewController to display it.

For reference you can see this link. It works for iOS 8 only.

Upvotes: 0

Nilesh Patel
Nilesh Patel

Reputation: 6394

Try below thing,

var alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.ActionSheet);
alert.view.addSubview([YOUR CUSTOMR VIEW]);

Hope its helps..

Upvotes: 5

Related Questions