简体   繁体   English

AlertView中的图像在iOS7中不起作用

[英]Image in alertview is not working in ios7

I used the follwing code to add image in alert view. 我使用以下代码在警报视图中添加图像。 But its not working. 但是它不起作用。

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Popup" message:@"popup" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil];

UIImageView *tempImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gg.jpg"]];

tempImg.contentMode = UIViewContentModeScaleToFill;

tempImg.frame = CGRectMake(90, 40, 100, 120);

//    tempImg.image = [UIImage imageNamed:@"gg.jpg"];

[alert addSubview:tempImg];

[alert show];

Thanks in advance 提前致谢

You can not use addSubview to a UIAlertView from iOS 7. You have to make your own alertView if you want to customize it. 您不能在iOS 7中将addSubview用于UIAlertView。如果要自定义,则必须创建自己的alertView。 There are also lots of custom alertview available on net. 网上也有很多自定义的alertview。 You may try this one . 你可以试试这一个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM