2016-06-21 65 views
0

enter image description hereUIImage不顯示在UIAlertAction中?

我的代碼是這樣的:

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]; 

回答

0

不喜歡這種方式。它會幫助:

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];