ragu ragu - 5 months ago 35
Objective-C Question

UIImage is not show in UIAlertAction?

enter image description here

My code is like:

UIImage *imk= [UIImage imageWithData:imageData];



UIAlertController * alert= [UIAlertController
alertControllerWithTitle:@"Success"
message:@"Posted Successfully."
preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *Action=[[UIAlertAction alloc]init];
[Action setValue:imk forKey:@"image"];
[alert addAction:Action];

[self presentViewController:alert animated:YES completion:nil];

Answer

Do like this way.. it will help :

    UIAlertController * alert=   [UIAlertController
                                  alertControllerWithTitle:@"Success"
                                  message:@"Posted Successfully."
                                  preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction* action = [UIAlertAction
                     actionWithTitle:@"Title"
                     style:UIAlertActionStyleDefault
                     handler:^(UIAlertAction * action)
                     {
                         [view dismissViewControllerAnimated:YES completion:nil];

                     }];
[action setValue:[[UIImage imageNamed:@"img.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forKey:@"image"];
[alert addAction:action];
[self presentViewController:alert animated:YES completion:nil];
Comments